ASP.NET MVC Master Pages

Ash picture Ash · Jan 17, 2009 · Viewed 24.2k times · Source

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

Answer

Zhaph - Ben Duguid picture Zhaph - Ben Duguid · Jan 20, 2009

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.