Does master page get called first?

Serguei Fedorov picture Serguei Fedorov · May 8, 2012 · Viewed 12.2k times · Source

I would assume this is true, but wanted to throw this question up. Is the master page executed first in ASP.NET, or does the page which is getting retrieved?

I am asking because I want some processing to be done in the master page, results of which are loaded into a static object and which can then be used by the called page (for instance user data)

Answer

Tim Schmelter picture Tim Schmelter · May 8, 2012

Sorry for just quoting, but i don't know what to add:

Individual ASP.NET server controls have their own life cycle that is similar to the page life cycle. For example, a control's Init and Load events occur during the corresponding page events.

Although both Init and Load recursively occur on each control, they happen in reverse order. The Init event (and also the Unload event) for each child control occur before the corresponding event is raised for its container (bottom-up). However the Load event for a container occurs before the Load events for its child controls (top-down). Master pages behave like child controls on a page: the master page Init event occurs before the page Init and Load events, and the master page Load event occurs after the page Init and Load events.

http://msdn.microsoft.com/en-us/library/ms178472.aspx

enter image description here