Introduction :
In this tutorial will learn about _ViewStart.cshtml In ASP.NET MVC Core. In Razor Pages _ViewStart.cshtml file contains code that is executed at the start of each Razor Page’s execution.
The code in _ViewStart.cshtml file is executed before the code in an individual view is executed. Instead of setting the Layout property in each individual view, we can move that code into the _ViewStart.cshtml file.
If we have multiple _Viewstart.cshtml file in each view folder then _Viewstart.cshtml file under shared folder is overridden file individual view’s _viewstart_cshtml file , so _ViewStart.cshtml files are hierarchical.
if we have multiple layout selection as per role based then we can add conditional code block under _viewstart_cshtml file for rendering view for deferent user like AdminPanel or client panel.
Also Learn More Tutorial :
- ASP.Net Core: Form Submit (Post) with Example
- File(Image) Upload in ASP.NET Core MVC with Example
- .Net Core: Read Connection String from AppSettings.json file
- CRUD Operation Using Asp.Net Core Mvc with Repository Pattern
- Display Data in GridView(Grid) Using ASP.Net Core MVC
- Asp.Net Core: DbContext In EntityFramework core
- Difference between AddSingleton vs AddScoped vs AddTransient in asp.net core
- Difference between .NET Core and .NET Framework
- Difference between TempData keep() And Peek() in Asp.Net MVC
- Asp.Net Image Upload in 3-Tier Architecture and store in sql database