Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Master Pages

What's the difference between the ASP.NET Master Page, and the MVC Master Page? And the AJAX Master Page for that matter?

like image 874
Ash Avatar asked Jan 17 '09 02:01

Ash


People also ask

Can we create a master page in MVC?

Creating a View Master PageYou add a new view master page to an MVC project by right-clicking the Views\Shared folder, selecting the menu option Add, New Item, and selecting the MVC View Master Page template (see Figure 1).

What is the location of master page of MVC core web application?

Now open your Home, About, contact pages and check top line - MasterPageFile="~/Site. Master" that means you have included the master page in your current page. Run your application and check all pages, like Home, About, and Contact it will display Top Menu and Footer links along with the page content in the container.


1 Answers

Mostly it comes down to the default controls and inheritance.

The AJAX Master and ASP.NET Master both inherit from System.Web.UI.MasterPage, while the MVC Master inherits from ViewMasterPage.

Obviously, these give you slightly different controls on this - as stated by John Clayton, the ViewMasterPage exposes the Ajax/Html/Url helpers and the like, which are not available to the other MasterPages.

Other than that, the default controls are slightly different:

  • ASP.NET Master page will have the default Form and two ContentPlaceHolder controls (one in the head, one in the form.
  • AJAX Master page also adds a ScriptManager control inside the Form control.
  • MVC Master (depending on version - I'm refering to the Beta) will just have two ContentPlaceHolder controls (in head and body).

The "lifecycle differences" come from the Page/ViewPage, rather than the MasterPage/ViewMasterPage controls.

like image 121
Zhaph - Ben Duguid Avatar answered Oct 21 '22 15:10

Zhaph - Ben Duguid