Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Asp.net page life cycle stages

When you run asp.net page, page goes through life cycle in which performs series of steps. 

General page life cycle goes with following stages:

 

Page request:

When ASP.NET gets a page request, it decides whether to parse and compile the page, or there would be a cached version of the page; accordingly the response is sent.

Start:

In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property.

Initialization

At this stage, the controls on the page are assigned unique ID by setting the UniqueID property and the themes are applied. For a new request, postback data is loaded and the control properties are restored to the view-state values.

Page load

At this stage if current request is post back, control properties are set using the view state and control state values.

Rendering

If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. (There is an exception to this sequence: the handler for the event that caused validation is called after validation.)

Page rendering

At this stage, view state for the page and all controls are saved. The page calls the Render method for each control and the output of rendering is written to the OutputStream class of the Response property of page.

Unload

The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.

Advantages and disadvantages using InProc session sate

This mode stores the session data in the ASP.NET worker process.This is fastest among all of the storage modes.

Advantages:

1.  InProc is default session state configuration not required for State server and sql server external configuration required.
2.  You can save any object in session variable even if it is not serializable. For State and SQl server requires objects to be serializable.
3.  InProc mode works on shared web hosting. State Server is usually not allowed, and some shared web hosting providers give option to use SQL Server. In the other hand, InProc works in any hosting package.

Disadvantages:

1.  Reliability is first problem when using InProc. When using InProc mode, all sessions are lost whenever web application restarts.

2.   Scalability is one more problem when using InProc mode. Each user has its own collection of session variables. On high traffic websites, with thousands of visitors online, sesssion data easily grow and spend complete memory on web server.

3. There is a problem on web farms and web gardens. If you host website on web farm (multiple servers) or web garden (multiple processors) ASP.NET application will use multiple processes. Since InProc stores session data inside single process, session data will be lost when visitor request goes to different server or processor.

Aadvantages and disadvantages of Out-Proc (State Server) Session mode

In this mode, the session state is serialized and stored in memory in a separate process.

Advantages:

It keeps data separate from IIS so any issues with IIS will not hamper session data
It is useful in web farm and web garden scenarios.

Disadvantages:

Process is slow due to serialization and de-serialization.
State Server always needs to be up and running.