.Net 3 Flashcards
What is the purpose of _ViewImports.cshtml file?
In this file you can summarize (abstract) all using statements that you commonly use in all your views.
It is automatically imported into all views in the folder it belongs to and its subfolders. So if it is in View folder, then all your views will be affected.
What is the purpose of _ViewStart.cshtml file.
The common practice for ViewStart is to set up a default value that you can override for the Layout and the ViewData / ViewBag dictionary.
For example you can set default layout for all the views in the folder.
@{
Layout = “_Layout”;
}
It is automatically imported into all views in the folder it belongs to and its subfolders. So if it is in View folder, then all your views will be affected.
What is @RenderBody in _Layout.cshtml
It’s where the view, that uses this layout (child view), will be rendered.
How to inject a partial view?
Using tag <partial></partial>
What is specific of _ViewStart.cshtml for partial views?
Unlike MVC view or page rendering, a partial view doesn’t run _ViewStart.cshtml