In default mvc app. There are Layout and content pages, You know (_Layout, Home, Contact, etc.)
And content pages do not contain layout refrence as this:
Layout = "~/Views/Shared/_Layout.cshtml";
In content pages this code is missing. But they works. How does it do this without layout refrence?
Because your _ViewStart.cshtml
contains a reference to the default layout that will be used when a specific one is not stated on the view.
When you want to change the layout for a single view, you would include a Layout = "...";
to that view.
If you want folder specific layouts i.e. (Home, Account, Product etc), you can put _ViewStart.cshtml in that folder & point out whichever layout tobe used in that file & it will override the root level layout.
Find ScottGu's blogs for more details on layouts & sections here & here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With