views:

6538

answers:

3

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

A: 

As a quick guess I'd have to say that the answer would be "lifecycle". ASP.NET WebForms, MVC and AJAX all have different lifecycles which would effect the events which need to be responded to by a master page control. A WebForms Master Page would need to respond to Load, DataBind, PreRender, Render, etc. An MVC Master Page would probably (not sure on this) only need the Render action. All the other events are superfluous and the equivalent code would be found in the controller. Lastly, the AJAX Master Page would need to handle AJAX requests on top of normal ones.

As I said, this is a bit of a guess so more research is recommended

Wolfbyte
+1  A: 

The ViewMasterPage in MVC is little more than a master page that exposes the same helpers as the ViewPage. This gives you access to the AjaxHelper, HtmlHelper, TempDataDictionary, UrlHelper, ViewContext, ViewData, and the HtmlTextWriter.

Like the ViewPage, when you are using the WebFormsViewEngine (default), you should resist any urge to overload page lifecycle events at all costs! They are still there, and they will still run since under the hood ProcessRequest(...) is still called on the page.

Which AJAX master page are you referring to? I'm not familiar with any included with the framework...

John Clayton
+10  A: 

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.

Zhaph - Ben Duguid