Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP.NET MVC Baby Steps
Message
From
16/06/2013 03:47:08
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01576485
Message ID:
01576501
Views:
41
>>Hi,
>>I am looking at the training video (Pluralsight) on APS.NET MVC Basics (produced in 2009) the demo project. The Views folder has Home folder and Shared folder. The Home folder is clear, it has view files for each view the project needs.
>>
>>The Shared folder has page Site.Master which is the master page used by all views.
>>
>>In the current version of VS 2012, when I create a test ASP.NET MVC project, the Shared folder has file _Layout.cshtml.
>>
>>What is the purpose of _Layout.cshtml?
>>
>>And does it mean that VS 2012 does not automatically create file Site.Master (master page for the project) and I have to create it manually?
>>
>>TIA
>
>Interesting that the same guy, Scott Guthrie, refers to the ASP.NET MVC 3 master page as SiteLayout.cshtml ( http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx ) and in another artilce as _Layout.cshtml ( http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx ). No wonder I am confused <g>.

The process with Razor actually starts one step sooner than I mentioned in the other post.
_ViewStart.cshtml actually defines what will be used as the default master page.
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
but you could use any name you like. You can also add logic to _ViewStart.cshtml to point to a different master pages (perhaps based on the device type or region of the client). And, of course, you can, if you wish, override this for some views by defining a different (or no) master page when you create the view.
HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform