ASP.NET 1.1 Page Execution. Respect it.

There's probably been plenty written by this time on the execution lifecycle of ASP.NET v1.1 pages. However, I still run into a lot of issues and questions around what order events and methods get executed during the lifecycle of a request. Its essential to understand this order when debugging what can be complex bugs in Page and WebControl code.

Here's a short exercise that will help you internalize whats happening during the creation and execution of a page. Do this without looking up the answer, and it will really make you think through what is happening. Put the following events in order, assuming the request is a PostBack resulting from a Button click:

  • Unload
  • Pre-Render
  • Handle Postback Events
  • Dispose
  • Save State
  • Load View State
  • Load
  • Button Click Handler
  • Process Postback Data
  • Initialize
  • Send Postback Change Notifications
  • Render

You can lookup the answer in MSDN here, but realize that at least one of the events is out of order in the documentation.

Consider the events in you Global.asax class on the first request received by an application not yet started:

  • Authorize Request
  • Application Start
  • Authenticate Request
  • End Request
  • Page Execution
  • Begin Request
  • Session Start

The next time you try to access ViewState during the Init event, you'll know why it doesn't work correctly.

Print | posted on Friday, August 20, 2004 9:39 PM

Feedback

# re: ASP.NET 1.1 Page Execution. Respect it.

left by Paul Wilson at 8/20/2004 11:22 PM Gravatar
Maybe its late, and I'm tired, but which one in the docs do you think is out of order? Certainly there is a potential for a second attempt at processing of postback data at a later time, but that doesn't mean the main case is out of order.

# re: ASP.NET 1.1 Page Execution. Respect it.

left by Paul Wilson at 8/21/2004 11:06 AM Gravatar
Ah, I see -- it does look like Unload should come before Dispose -- unless of course you call it manually which I've never seen anybody do.

# help i wnt to clear my session variables

left by kunal at 3/23/2005 2:09 AM Gravatar
hi all

i wnt to clear my all session variable before redirecting the page to another page.

When shuld i do? In Page_unload?

kunal

Programmer [ Entry Level ]
Title  
Name
Email (never displayed)
Url
Comments   
Please add 2 and 3 and type the answer here: