I'm using ASP.NET MVC5, razor syntax. I need a specific "Create" view to NOT inherit the _Layout.cshtml
Shared View.
Basically, in this particular View, I don't want any of the _Layout.cshtml
features like the navigation menu, footer, etc.
The _ViewStart. cshtml page is a special view page containing the statement declaration to include the Layout page. Instead of declaring the Layout page in every view page, we can use the _ViewStart page. When a View Page Start is running, the “_ViewStart.
The file "_Layout. cshtml" represents the layout of each page in the application. Right-click on the Shared folder in Solution Explorer then go to "Add" item and click on "View". Now the View has been created.
The default _ViewStart. cshtml is included in the Views folder. It can also be created in all other Views sub-folders. It is used to specify common settings for all the views under a folder and sub-folders where it is created.
The _ViewImports. cshtml file for an ASP.NET Core MVC app is typically placed in the Pages (or Views) folder. A _ViewImports. cshtml file can be placed within any folder, in which case it will only be applied to pages or views within that folder and its subfolders.
Use.
@{
Layout = null
}
In whatever .cshtml
file you don't want to inherit the _layout.cshtml
It inherits Layout because of your _ViewStart.cshtml
file. Look at your ViewStart and delete related line. Then if you want to use Layout in your page you have to specify your Layout in each page.
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