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

3

8

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

Additive answered 18/5, 2011 at 15:53 Comment(0)
J
22

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

Johannesburg answered 18/5, 2011 at 15:58 Comment(0)
C
3

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;
}
Carnegie answered 18/5, 2011 at 16:2 Comment(0)
E
1

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

@{
 Layout = ...
}
Enamelware answered 18/5, 2011 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.