O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Page Layout with Razor

Much of your page markup is common across views such as navigation, header, footer, general look and feel, and more. You want to write this markup once and use it everywhere. ASP.NET MVC provides _ViewStart.cshtml and _Layout.cshtml for this purpose. Note that the underscore used in the name of a page is a common way to indicate that the page is shared (and not accessed directly by a user).

The default _ViewStart.cshtml page sits inside the root of your Views folder in Solution Explorer. The ASP.NET runtime knows to look there to find a common layout for your pages. The following shows an example of the content in this page.

@{  Layout = "_Layout.cshtml";}

Notice that this default view start ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required