ViewMasterPage - what is MVC 3's Razor Equivalent?
I'm conv开发者_StackOverflowerting MVC 2 over to MVC 3, and I have a custom class that inherits from System.Web.Mvc.ViewMasterPage for my Default.Master file.
When converting over to MVC 3, I still want to have a custom class for my Layout.cshtml file, but what should I inherit from? I'm looking for something like System.Web.Mvc.ViewLayoutPage and System.Web.Mvc.ViewLayoutPage<>, but they do not exist.
Thanks!
There is no equivalent. Master pages in Razor are simple .cshtml files. In fact there is no distinction between a view and a layout. Both are simple .cshtml templates. It's only the ~/Views/_ViewStart.cshtml file which specifies which layout to be used by default. Obviously you could always create a custom layout template in the ~/Views/Shared folder and then specify it either in the ~/Views/_ViewStart.cshtml or override it in each specific view or also in the controller action when returning a view you have the possibility of specifying a master page.
For more information about Razor views you may checkout the following blog post.
加载中,请稍侯......
精彩评论