What is _Viewstart in ASP.Net MVC

Viewed 6615

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.

1 Answers

_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.

Related