JanNet
JanNet

Reputation: 11

Replace Webforms MasterPage with MVC _Layout.cshtml

I have a ASP.NET webforms project that has 100 plus web pages. All these pages have common Site.master master page.

We have started to convert our webforms project to MVC. So in MVC we have the _Layout.cshtml as our new Master Page. Everything from Site.master has been copied to _Layout.cshtml. Site.master is now blank.

Now I want to know how all the 100 plus web pages in my project can call this new MVC Layout.cshtml. So instead of calling Site.master, all the pages in my project should use Layout.cshtml as the new master page.

Upvotes: 1

Views: 1768

Answers (1)

Ortund
Ortund

Reputation: 8245

You have to migrate over the whole website.

That means creating new views and controllers on the MVC site for the pages on the ASP.NET site.

Once you have a Controller with the Actions for the Views, simply add the following to the top of the View to use the Layout page:

@{
    Layout = "<path_to_layout.cshtml>";
}

Upvotes: 1

Related Questions