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:
<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
And
An expression tree may not contain a dynamic operation
How do I register a generic page base class with ASP.NET MVC4 without using the @inherits
keyword in each Razor view?