| ASP.NET Application Phases |
| |
| Page Life Cycle |
| |
| When a web page is sent to the Web Server for processing, it goes through a series of steps before it finally gets displayed in the Web Browser. There are various application steps in addition to page life-cycle steps that occur before and after a request but are not specific to a page. Generally, the page goes through the various steps given below. |
| |
⢠Page Request: For a page requested by a user, ASP.NET have to verify whether the page needs to be parsed and compiled or whether a cached version of the page can be sent in response without running the page. There fore, the page request occurs before the beginning of page life cycle.
⢠Start: During the start step, page properties like Request and Response are set. At this stage, the page also decides whether the request is a PostBack or a new request and sets the IsPostBack property. In the start step, the UICulture property of the page is also set.
⢠Page Initialization: During page initialization, the ASP.NET page framework restores the control properties and PostBack data. All the controls that are statically declared in the .aspx file will be initialized with the default values. Controls can use this event to initialize some of the settings that can be used throughout the lifetime of the incoming web request. ViewState information will not be available at this stage.
⢠Load: After initialization the next is the load step, if the current request is a PostBack, control properties are loaded with information recovered from view state and control state.
⢠Validation: The Validate method of any validator Web server controls is invoked to perform the control's specified validation during the validation step of the page. The done by setting the IsValid property of each validator controls and of the page.
⢠PostBack Event Handling: The PostBackData event gives control a chance to update their state that reflects the state of the HTML element on the client. After the server-side events invoke on data that was changed due to PostBack updates, the object which caused the PostBack is handled at the RaisePostBackEvent event.
⢠RaisePostBackEvent: This event fires last in the series of PostBack events due to the accuracy of the data that is rendered to the browser. Controls that are changed during PostBack should not be updated after the executing function is called due to the consistency factor.
⢠Rendering: View state is saved for the page and all controls, the before rendering. During the rendering stage, the page invokes the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
⢠Unload: The final stage of the page life cycle is unload event. This is invoked just before the page object is released. In this event, you can release vital resources you have like database connections, files objects etc cleanup is performed. After this event browser receives the HTTP response packet and displays the page. |
| |
| When the HTTP page handler class is fully recognized, the ASP.NET runtime calls the handler's ProcessRequest to start the process. This execution begins by calling the method FrameworkInitialize(), which builds the control trees for the page. |
| |
| After that processRequest() makes page transits various stage: initialization, loading of viewstate and postback data, loading of page's user code and execution postback server-side events. Then page enters in rendering mode, the viewstate is updated and HTML generated is sent. Finally page is unloaded and request is considered completely presented. |
| |
| The various phases in the life cycle of the ASP.NET page cycle are following: |
| |
⢠Initialization of the Page
⢠Loading View State information
⢠PostBack data processing
⢠Loading the Page
⢠PostBack Change Notification
⢠PostBack Event Handling
⢠Page Pre Rendering Phase
⢠Saving the View State information
⢠Rendering of the Page
⢠Unloading Page from memory |
| |
|
| |