_ViewStart.cshtml In ASP.NET MVC Core

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.

 

_ViewStart.cshtml In ASP.NET MVC Core

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 :

 

Leave a Reply

Your email address will not be published. Required fields are marked *