Asp.net life cycle

 Page Life Cycle In ASP.NET

Asp.net life cycle


In general, when a user request a page through his/her browser then page goes through several stages outlined in the following list. In addition to the page life-cycle stages, there are application stages that occur before and after a request but are not specific to a page. The stages are:-

1. Page Request: - Page Request occurs before page life cycle begins. When user requested the page, ASP.Net determines that the page is needed to be parsed and compiled or whether a cached version of the page can be sent in response without running the page.

2. Start: - In the start stage, page properties such as Request and Response is set. At this stage, page also determines that request is post back or a new request and sets the IsPostBack property.

3. Page Initialization: - During page initialization, controls on the page are available and each control’s UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.

4. Load: - During Load, if the current request is postback, control properties are loaded with information recovered from view state.

5. Validation: - During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.

6. Postback Event Handling: - If the request is a postback, any event handlers are called. The event handling for server controls occurs during this stage.

7. Rendering: - Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutPutStream object of the page's Response property.

8. Unload: The rendered page is sent to the client and page properties, such as Response and Request are unloaded and all cleanup done.

No comments