Reputation: 101
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.
Upvotes: 8
Views: 13251
Reputation: 1627
_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.
Upvotes: 15