开发者

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

开发者 https://www.devze.com 2023-02-09 01:32 出处:网络
I\'m currently using this syntax to specify a custom Razor page base class and model type: @inherits MyWebViewPage<MyModel>

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

精彩评论

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