How to make a certain View in MVC not inherit _Layout.cshtml?

Mike Marks picture Mike Marks · Jan 2, 2014 · Viewed 12.7k times · Source

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.

Answer

Nico picture Nico · Jan 2, 2014

Use.

@{
    Layout = null
}

In whatever .cshtml file you don't want to inherit the _layout.cshtml