I’m converting 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
.cshtmlfiles. In fact there is no distinction between a view and a layout. Both are simple.cshtmltemplates. It’s only the~/Views/_ViewStart.cshtmlfile which specifies which layout to be used by default. Obviously you could always create a custom layout template in the~/Views/Sharedfolder and then specify it either in the~/Views/_ViewStart.cshtmlor 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.