注册通用页面基类 [英] Register generic page base class

查看:137
本文介绍了注册通用页面基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建我自己的通用页面的基类:

I create my own generic page base class:

public abstract class ViewPageBase<TModel> : WebViewPage<TModel>
{
    public ParamBuilder<TModel> Param { get { return new ParamBuilder<TModel>(Model); } }
}

Web.config文件:

Web.config:

<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <pages pageBaseType="ViewPageBase">
    <namespaces>
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />
    </namespaces>
  </pages>
</system.web.webPages.razor>

此输入会导致以下错误:

This entry causes the following errors:

INCORRECT_TYPE_PARAMETER_NUMBER

INCORRECT_TYPE_PARAMETER_NUMBER

这是前pression树不能包含动态操作

An expression tree may not contain a dynamic operation

我如何注册ASP.NET MVC4一个通用的页面基类无需在每个的Razor视图使用 @inherits 关键字?

How do I register a generic page base class with ASP.NET MVC4 without using the @inherits keyword in each Razor view?

推荐答案

这应该工作。您得到的错误是不相关的自定义视图页面。

This should work. The error you are getting is not related to the custom view page.

这篇关于注册通用页面基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆