Thursday, July 15, 2010

ASP.NET Page Life Cycle

This blog demonstrates ASP.NET Page Life cycle and a series of processing steps and when an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering.

Below picture depicts whole asp.net page life cycle process and define all possible stage

ASP.NET Page Life Cycle
ASP.NET Page Life Cycle


The life cycle of an ASP.NET application starts when a request is sent by the browser to the web server [Internet Information Service (IIS)], the request is forwarded to Internet Server Application Programming Interface (ISAPI).

ISAPI is an N-tier API of Internet Information Services (IIS), Microsoft's collection of Windows-based web server services. ISAPI checks the extension of a file which is requested by the browser and based on that, it loads the HttpHandler and module which is responsible for handling the request.



ASP.NET HTTP RUNTIME

Application Manager create an application domain from application pool and after that ASP.NET creates an object of HttpRequest and HttpResponse for each request sent to the ASP.NET Web App and after that ASP.NET create the HttpApplication object, which invoke asp.net page life cycle process.

What is ASP.NET HttpRuntime

ASP.NET Page Life Cycle Phases:

  • Initialization
  • Load View State
  • Pre-Render
  • Save View State
  • Render
  • Unload

Initialization : 
During Initialization phase, all controls object on the page has been created and applied Unique ID to each control. Master page and themes are also applied to the page.

If the current request is a post-back, the post-back data has not yet been loaded and control property values have not been restored to the values from view state.

Load View State :
During Load phase, if the current request is a post-back, control properties are loaded with information recovered from view state and control state.

Pre-Render :
During Pre-render, we can make final changes to the page properties or control properties.

Save View State :
During Save View phase, it saves view state for the page and all control and now it is ready for rendering.

Render :
During the rendering phase, the page calls the Render method for each control and it returns html text response and set Page’s response property.

Unload :
Once Page is fully rendered and sent to client browser and after it destroy Page object now perform cleanup.

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...