7

Actually we can use layout in our cshtml page. Then what is the need of using _Layout path in _Viewstart page.

Can I write the code of _Layout in _Viewstart page.

Shashi
  • 91
  • 1
  • 1
  • 6
  • Possible duplicate of [Where and how is the \_ViewStart.cshtml layout file linked?](https://stackoverflow.com/questions/9300410/where-and-how-is-the-viewstart-cshtml-layout-file-linked) – Uwe Keim Jan 06 '19 at 11:19

1 Answers1

13

_Viewstart Page Introduced in ASP.NET MVC 3

The _ViewStart.cshtml page is a special view page containing the statement declaration to include the Layout page.

Instead of declaring the Layout page in every view page, we can use the _ViewStart page.

When a View Page Start is running, the “_ViewStart.cshtml” page will assign the Layout page for it.

and also provide more maintainability to our application.

Note: if we want to set views in a specific folder to use a different layout file then you can include another _viewStart.cshtml file in that specific folder.

Rehan Shah
  • 1,505
  • 12
  • 28