Jeff and .NET

The .NET musings of Jeff Putz



My Sites


Application, Page and Control events in ASP.NET v2.0

It appeared to me that they added a few things here and there to the Application, Page and Control lifecycle in ASP.NET v2.0. Curious, I whipped up some derived classes to output to a text file every time one of these events fired in the grand scheme of a request. I wired in the basic events then did overrides for everything that appeared to fire at some point. I think it's mostly complete, but the data binding events don't appear to fire unless you've got some data binding to do...

Edit 7/4: I added the postback events in there, as well as data binding for the control. However, keep in mind that the data binding for the control is, in this case, called from the page's Load handler. Naturally it's common to do this in PreRender as well, so it could also appear there.

Application: BeginRequest
Application: PreAuthenticateRequest
Application: AuthenticateRequest
Application: PostAuthenticateRequest
Application: PreAuthorizeRequest
Application: AuthorizeRequest
Application: PostAuthorizeRequest
Application: PreResolveRequestCache
Application: ResolveRequestCache
Application: PostResolveRequestCache
Application: PreMapRequestHandler
Page: Construct
Application: PostMapRequestHandler
Application: PreAcquireRequestState
Application: AcquireRequestState
Application: PostAcquireRequestState
Application: PreRequestHandlerExecute
Page: AddParsedSubObject
Page: CreateControlCollection
Page: AddedControl
Page: AddParsedSubObject
Page: AddedControl
Page: ResolveAdapter
Page: DeterminePostBackMode
Page: PreInit
Control: ResolveAdapter
Control: Init
Control: TrackViewState
Page: Init
Page: TrackViewState
Page: InitComplete
Page: LoadPageStateFromPersistenceMedium
Control: LoadViewState
Page: EnsureChildControls
Page: CreateChildControls
Page: PreLoad
Page: Load
Control: DataBind
Control: Load
Page: EnsureChildControls
Page: LoadComplete
Page: EnsureChildControls
Page: PreRender
Control: EnsureChildControls
Control: PreRender
Page: PreRenderComplete
Page: SaveViewState
Control: SaveViewState
Page: SaveViewState
Control: SaveViewState
Page: SavePageStateToPersistenceMedium
Page: SaveStateComplete
Page: CreateHtmlTextWriter
Page: RenderControl
Page: Render
Page: RenderChildren
Control: RenderControl
Page: VerifyRenderingInServerForm
Page: CreateHtmlTextWriter
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose
Application: PostRequestHandlerExecute
Application: PreReleaseRequestState
Application: ReleaseRequestState
Application: PostReleaseRequestState
Application: PreUpdateRequestCache
Application: UpdateRequestCache
Application: PostUpdateRequestCache
Application: EndRequest
Application: PreSendRequestHeaders
Application: PreSendRequestContent

Anyone have something to add?

Posted: Jul 04 2004, 01:12 AM by Jeff | with 30 comment(s)
Filed under:


AndrewSeven said:

# July 4, 2004 10:52 AM

Eric Newton said:

damn thats a lot of events.
# July 4, 2004 6:49 PM

Ade Bryer said:

Any chance you could post the code on here. I would be interested to see how you implemeted this.

# August 10, 2006 5:34 PM

David said:

What about LoadPostData and LoadViewState

# August 14, 2006 5:09 PM

DT said:

Do you know why the SaveViewState events fires twice for page and control?

 Page: SaveViewState

 Control: SaveViewState

 Page: SaveViewState

 Control: SaveViewState

# August 29, 2006 9:40 PM

Naren said:

Thanks for the article.

# August 30, 2006 10:32 PM

Orlin Georgiev said:

It seems you've been looking at some kind of Beta release. There are no such events as PreAuthenticateRequest, PreAuthorizeRequest, PreResolveRequestCache, PreAcquireRequestState, PreAcquireRequestState, PreReleaseRequestState and PreUpdateRequestCache in the ASP.NET 2.0 HttpApplication class (referred to you as the "Application"), not even private or internal ones. Decompile the System.Web.dll with the Reflector, if you like. Besides, you've missed the HttpSessionState.Start (Session_Start) and HttpSessionState.End (Session_End) events. Start occures just before AcquireRequestState and End occurs some configurable interval after the last request. Otherwise, this is an excellent list, it seems it will help me big with the page/control lifecycles.

# December 21, 2006 1:20 AM

Jeff said:

Of course it's based on pre-release... the post is more than two years old! Look at the date before you start lecturing.

# December 21, 2006 8:58 AM

Igor said:

Hi Jeff

The date published is a bit hidden in the GUI of the post. Usually in news publishing the date of the article is shown in other sytle(color) underneath the article title. In case of your blog the datestamp of your entry is mentioned underneath the body text. I had to look for a while (after reading your comment "Of course it's based on pre-release... ") to find the date.

But anyhow. Thanks for writing down a list of events :)

# February 18, 2007 7:37 PM

Ajai said:

It's really nice.but no body has given the answer of

"Do you know why the SaveViewState events fires twice for page and control?"

# March 2, 2007 1:24 AM

Bruno Correa said:

I really would like to see control events there, such as the button click event... and session events, thanks!

# March 7, 2007 6:49 AM

David said:

When do OnInit(EventArgs e), OnLoad etc come in?

# June 13, 2007 8:28 AM

Manjit said:

Fantastic! Just the thing I've been looking for. Thanks a lot.

# July 2, 2007 2:39 AM

FIX said:

when the events are triggered?!

# July 24, 2007 1:30 AM

Praveen K Prasad said:

This is a s**t load of events. :)

Thanks Dear

# August 2, 2007 11:50 AM

challen said:

it is great. thanks!

# August 22, 2007 6:21 AM

Sachin Ambekar said:

Hey..Its a great insight of the Page Life Cycle. I understand the Page Life Cycle is utmost important in order to expertise in Web Development projects.

Thanks in tonnes.

# October 1, 2007 2:46 AM

Nick said:

Thanks for this!

# December 19, 2007 12:05 PM

Bassem Murad said:

hello Jeff,

Thx for the gr8 help..but can u provde us with the latest list of events' sequence. it would e of trumendous help.

Thx man and keep up the good work...

# February 14, 2008 1:45 PM

Shane Brown said:

Is this just a trace output.!

# February 20, 2008 9:41 AM

Batott said:

Thanks dude

# April 3, 2008 3:25 PM

Makkawey Mohammed said:

How Can I use dispose Method In user Control

# April 20, 2008 7:36 AM

mlogan said:

It may be helpful to put in Masterpage events in here.

# May 16, 2008 8:39 AM

nil karaibrahimgil said:

Thanks for every information.

These are very useful!

Thank you so much...

King Regards!

# July 12, 2008 2:47 AM

Mukund said:

It would be nice if these events have their explanation.. And in control events shall we add all control events like gridview's rowcommand event etc

# September 2, 2008 3:36 AM

Ashish said:

I am handling Page_PreRender event and overiding Control.OnPreRender. Strange thing is that if I handle Page_PreRender event, my control's OnPrerender doesnt gets executed at all. When I remove the Page_PreRender event it gets executed. any ideas?

# October 16, 2008 12:17 PM

Caxey said:

Just asking what event acctually invoke after set all postback data to the control ?

# October 19, 2009 2:34 AM

Inder said:

Please explain every event...

# April 26, 2010 2:44 AM

Vikr@m said:

Which are the ASP.Net Controls doesn't have events??

This is a question which was ask to me in an interview.

# July 28, 2010 12:36 AM

Carl said:

This must be my most referenced bookmark on ASP.Net.  Thanks!

# October 6, 2010 7:05 AM
Leave a Comment