开发者

ASP.NET MVC - Forcing custom base class for Razor (cshtml) files

I'm currently using this syntax to specify a custom Razor page base class and model type:

@inherits MyWebViewPage<MyModel>

Newer builds of Razor support a new directive to simplify this code:

@model MyModel

I'd like to use this but I c开发者_如何学Goan't find a way to make it work with my custom base class. Is there a way to specify this at a global level for my site?


In views/web.config modify

<pages pageBaseType="System.Web.Mvc.WebViewPage"> 

to your class


Tried to specify this in Views/Web.config?

<system.web.webPages.razor>
    <pages pageBaseType="MyUberCustomBaseClass">
    </pages>
  </system.web.webPages.razor>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜