Master Page does not appear in the list when I try to associate it with a view

3

I'm using Microsoft Visual Studio 2013 and I created a C # ASP.NET MVC 4 project.

I created a Master Page in the Views directory, called Modelo.master . Then I created a Controller in the directory Controllers , and again a View that would display the Controller output. However, in the Views creation screen where the program asks you to select a Master Page or layout to use as the base of the page I can not see Master Page I created. The Modelo.master file does not even appear in the list.

What could it be?

    
asked by anonymous 15.10.2014 / 18:23

1 answer

3

In Razor, the Master Page template is not used. What exists are Layout files, used by View to build.

Unlike Master Pages , where you specified content sections by using their own tag set, Razor uses pure HTML, rendering notations, and returning more HTML. The approach is simpler and less error prone on the part of the server.

Normally the Layout file of the main view (that is, the one that opens in a computer browser) is within Views\Shared with the name of _Layout.cshtml , but nothing prevents you from changing that name. Other Layout files common to the system should be placed in this directory. Layouts that are specific to certain Views belonging to a Controller can be in the specific directory of those Views .

The Wizard you just run generates a View with the following statement, which is completely optional:

@{
    Layout = "~/Views/Caminho/Da/Minha/View/_Layout.cshtml";
}

This statement is also found in the special view _ViewStart.cshtml , which starts a default Layout if no Layout is specified:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
    
16.10.2014 / 20:43