How to override the layout defined in _ViewStart for specific views in ASP.NET MVC 3?

Is it possible to suppress the layout expressed in _ViewStart.cshtml using ASP.NET MVC 3 for certain types of applications.

I understand that I can programmatically determine the layout in a controller action. Perhaps the transition to "" achieves this?

+8
c # asp.net-mvc asp.net-mvc-3
source share
2 answers

You have two options.

1) Use return PartialView() on the controller, it will not accept the layout from the View window

2) Assign layout = null,

  @{ Layout = null; } 

End this interesting discussion and answer marcind around this topic.

+22
source share

In order not to apply the layout, just set null to the Layout property in your view:

 @{ Layout = null; } <!DOCTYPE html> ... 
+2
source share

All Articles