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