asp.net-mvc-3razorlayoutmaster-pages

Master page not available as LayoutPage when creating view


I've saved a site.master file to my view\shared folder. When assigning a new view to the controller I check the Use layout or master page from the Add view dialog.

When browsing the view/shared folder only .cshtml files are available, not the .master file.

I am using the Razor View Engine.

Why am I not able to select the site.master file?


Solution

  • The Razor view engine doesn't use a .master file. This is specific to the WebForms view engine. Razor uses a layout file corresponding to ~/Views/Shared/_Layout.cshtml. So save your custom master as a .cshtml file in the ~/Views/Shared folder and it will appear when adding a new view.