Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register generic page base class

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?

like image 548
Rookian Avatar asked Jul 29 '12 18:07

Rookian


1 Answers

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

like image 167
Darin Dimitrov Avatar answered Sep 21 '22 01:09

Darin Dimitrov