Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an MVC3 site where I have some pages that I don't want to use the master page layout. The default master page is specified in the _ViewStart file so gets applied to everything.

How do I configure things so that some pages are displayed without the master page ?

Thanks

Matt

like image 356
Matt Avatar asked May 18 '11 15:05

Matt


3 Answers

Just place @{ Layout = null; } at the beginning of your view file.

like image 98
oryol Avatar answered Oct 03 '22 19:10

oryol


I'm not really clear if you mean to ask "how do I render a partial view?" or "how do i choose a different master page?"

If you want to render partial just use

@Html.Partial()

If you want to change the layout add someting like ..

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

If you want no layout ..

@{
    Layout = null;
}
like image 40
EBarr Avatar answered Oct 03 '22 19:10

EBarr


You can set the Layout property of that specific page, e.g. in Razor:

@{
 Layout = ...
}
like image 28
devdigital Avatar answered Oct 03 '22 17:10

devdigital