Aleksei Chepovoi
Aleksei Chepovoi

Reputation: 3955

How to change _layout for already created view in asp.net mvc 3?

If I already created a bunch of views is there any way to change their layout pages?

Upvotes: 0

Views: 78

Answers (1)

Kevin Junghans
Kevin Junghans

Reputation: 17540

You can change the default layout page for the whole application in the file _ViewStart.cshtml. By default it has the the following code:

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

This specifies that if any of your views do not explicitly state which layout to use they will use this layout.

Or, you can add code to your views (like above) that explicitly states which layout to use.

Upvotes: 1

Related Questions