Register the base class of the main page

I create my own common 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

The expression tree may not contain a dynamic operation

How to register a base class of a shared page with ASP.NET MVC4 without using the @inherits in each Razor view?

+6
source share
1 answer

That should work. The error you are getting is not related to the user view page.

+2
source

Source: https://habr.com/ru/post/921616/


All Articles