Monday, August 9, 2010

Life Cycle of an ASP.Net web page

Life Cycle of an ASP.Net web page

The life cycle starts when a user requests a Web page through his or her browser. The Web server then processes the page through a series of stages before returning the results back to the user’s browser. These processing stages define the life cycle of a Web page. Understanding how ASP.NET processes a Web page on the server is key to being able to successfully develop Web applications.

1. page request: Compile page (if necessary) Pull from cache (if available)

2. Start: Set request and response. Determine IsPostback.

3. Page Init: Initialize page controls (but not their properties). Apply page theme.

4. Load: If PostBack, load control properties from view state.

5. Validation: validate page and validator controls.

6. Post back Event handling: Call control event handlers (for post back requests).

7. Rendering: Save ViewState. Render controls and output the page.

8. Unload: Unload Request and Response. Perform clean-up. Page is ready to be discarded.

When a Web page is requested, the server creates objects associated with the page and all of its child control objects and uses these to render the page to the browser. Once the final stage is complete, the Web server destroys these objects to free up resources to handle additional requests.

No comments: