Creating _ViewStart.cshtml

The _ViewStart file can be used to define common view code that you want to execute at the start of each view's rendering. Because this code executes at the start of each view, we no longer need to explicitly set the layout in any of our individual view files.

Right-click on the Views folder and select Add New Item from the context menu. Then, select MVC View Start Page from the Add New Item dialog box, as shown in the following screenshot:

When you click on the Add button, it will create a file with the following content:

@{
Layout = "_Layout";
}