How to make pages not use the main page in ASP.NET MVC 3

I have an MVC3 site where I have several pages on which I do not want to use the layout of the main page. The main page is specified by default in the _ViewStart file, so it applies to everything.

How do I set things up so that some pages appear without a homepage?

thanks

Matt

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

Just put @{ Layout = null; } @{ Layout = null; } to the top of your view file.

+20
source share

I don’t quite understand if you want to ask: "How to make a partial presentation?" or "how to choose another homepage?"

If you want to make partial simple use

 @Html.Partial() 

If you want to change the layout, enter someting like ..

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

If you do not need a layout.

 @{ Layout = null; } 
+3
source share

You can set the Layout property for this particular page, for example. in razor:

 @{ Layout = ... } 
+1
source share

All Articles