General page life cycle stage
In general, pages go through each of the stages outlined in the following table. In addition to the page life cycle phase, there is an application phase before and after the request, but these stages are not specific to the page. For more information, see ASP. NET Application Life cycle Overview.
Page request |
Page requests occur before the page life cycle begins. When a user requests a page, ASP. NET determines whether the page needs to be parsed and compiled (thereby starting the life cycle of the page), or whether the cached version of the page can be sent in response without running the page. |
Begin |
In the start phase, page properties, such as Request and Response, are set. At this stage, the page also determines whether the request is a postback request or a new request, and sets the IsPostBack property. Also, during the start phase, the UICulture property of the page is set. |
Page initialization |
During page initialization, the controls in the page can be used, and the UniqueID property of each control is set. In addition, any theme will be applied to the page. If the current request is a postback request, the postback data has not yet been loaded, and the control property value has not been restored to the value in view state. |
Load |
During load, if the current request is a postback request, the control property will be loaded with information recovered from view state and control state. |
Verify |
During validation, the Validate method for all validator controls is invoked, and this method sets the IsValid properties for each validator control and page. |
Postback event handling |
If the request is a postback request, all event handlers are called. |
Present |
View state is saved for the page and all controls before rendering. During the rendering phase, the page calls the Render method for each control, and it provides a text writer to write the output of the control to the outputstream of the Response property of the page. |
Unloading |
The unload is called when the page is fully rendered and the page has been sent to the client, and the page is ready to be discarded. At this point, the page properties (such as Response and Request) are unloaded and cleanup is performed. |
The life cycle of a Web page, interviews are often asked