Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable layout in ASP.NET MVC?

Tags:

asp.net-mvc

In MonoRail you can just CancelLayout() to not render the layout. In ASP.NET MVC, the only way to affect the layout seems to be to pass the layout name into the View() method like View("myview", "mylayout"); only it seems that passing null or an empty string doesn't do what I'd want.

I ended up creating an empty layout that just rendered the content, but that seems silly.

"Not Render the layout" means exactly that. In the web forms view engine they call layouts "master pages". I want to render just my action's view and not surround it with the master page.

like image 995
Aaron Jensen Avatar asked Oct 20 '08 23:10

Aaron Jensen


1 Answers

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

   @{     Layout = "";         } 
like image 96
expdiant Avatar answered Sep 24 '22 23:09

expdiant