Disable layout in ASP.NET MVC?

At the beginning of view add this:

@{
    Layout = null;
}

If you want style sheet to remain, you'll need to add reference to it in that view.


To disable this for all pages, edit the _ViewStart.cshtml (in the root, under the 'Views' folder), and ensure that it contains the following:

@{
  Layout = null;
}

And to enable the template for any specific view, the following can be added to the .cshtml file for that view, to enable the template:

@{
  Layout = "~/Views/Shared/_Layout.cshtml";
}

In MVC 3, you can remove the master layout code with:

   @{
    Layout = "";    
    }

Tags:

Asp.Net Mvc