ASP.NET life cycle guides in a brief tutorial about how :

- ASP.NET forms pages to create dynamic yield

- ASP.NET accumulates the pages progressively

- The application and its pages are initiated and handled

The ASP.NET life cycle could be partitioned into two gatherings:

- Application Life Cycle

- Page Life Cycle

ASP.NET Application Life Cycle

The application life cycle has the certain accompanying stages:

- Client makes a manual request for getting access to the source page. Program sends this request to
the web server.

- A common pipeline gets the main request and the accompanying situations take place:

- An object of the class ApplicationManager is made.

- An object of the class HostingEnvironment is made to give manual data with respect to the assets.

- Top level things in the application are assembled.

- Reaction articles are made. The application protests, for example, HttpContext, HttpRequest and
HttpResponse are made and introduced.

- An occurrence of the HttpApplication article is made and doled out to the request.

- The request is handled by the HttpApplication class. Diverse occasions are raised by this class for
handling the request.


ASP.NET Page Life Cycle

At the point when a page is requested for, it is executed into the server memory, handled, and sent to the program. Later it is unloaded from the memory. In between at every stage, techniques and events are accessible, which could be rejected or canceled by need of the application. Rather, you can compose a manual particular code to reject the default code.

The Page class makes a tree arranged in order of ranks, of all the controls on the page. All the elements of the page beside the directives, are a part of this control tree.
You can see the control tree by including trace= “valid” to the page mandate. We will cover page directives and following under “directives” and ‘event handling’.

The page life cycle stages are:

- Initialization

- Creation of the controls on the page

- Rebuilding and support of the state.

- Execution of the event handler codes

- Page rendering

A thorough tutorial of Page cycle proves benificial in any stage of page life cycle. Execution of Page Life Study can help in solving all errors in between any stage of Page Life. This Tutirial additionally helps in creating custom controls and executing them at ideal time, generate their properties with perspective state information and run control behaviour code.

Taking after are the distinctive phases of an ASP.NET page:

- Page request
When ASP.NET gets a page demand, it chooses whether to parse and order
the page, or there would be a cached version of the page; in like manner the reaction is sent.

- Beginning of page life cycle
At this stage, the Request and Response objects are set. In the event that
the request is an old demand or post back, the IsPostBack property of the page is set to genuine.
The UICulture property of the page is additionally set.

- Page initialization
At this stage, the controls on the page are relegated unique ID by setting the
UniqueID property and the themes are applied. For another requests, postback information is
stacked and the control properties are reestablished to the view-state values.

- Page load
At this stage, control properties are set to utilize the view state and control state

- Validation
Validate technique for the approval control is called and on its fruitful execution, the
IsValid property of the page is set to genuine.

- Postback occasion handling
If the request is a postback (old demand), the related event
handler is appealed

- Page rendering
At this stage, view state for the page and all controls are spared. The page calls the
Render technique for every control and the yield of rendering is composed to the OutputStream class
of the Response property of page.

- Unload
The rendered page is sent to the customer and page properties, for example, Response and
Request, are emptied and all cleanup is done.

ASP.NET Page Life Cycle Events -

At every phase of the page life cycle, the page raises a few events, which could be coded. Event handling is essentially a capacity or subroutine, bound to the event, utilizing definitive traits, for example, Onclick or handle.

Taking after are the page life cycle occasions:

- PreInit
PreInit is the principal event in page life cycle. It checks the IsPostBack property and figures out if the
page is a postback. It sets the themes and master pages, makes dynamic controls, and gets and sets
profile property estimations. This event handling can be taken care of by over-burdening the
OnPreInit strategy or making a Page_PreInit handler.

- Init
Init event introduces the control property and the control tree is constructed. This event handling can
be taken care of by over-burdening the OnInit strategy or making a Page_Init handler.

- InitComplete
InitComplete occasion permits following of view state. All the controls turn on view state following.

- LoadViewState
LoadViewState occasion permits loading view state data into the controls.

- LoadPostData
During this stage, the elements of all the information fields are characterized with the <form> tag are

- PreLoad
PreLoad happens before the post back information is loaded in the controls. This event can be taken
care of by over-burdening the OnPreLoad technique or making a Page_PreLoad handler.

- Load
The Load event is raised for the page first and after that repeatedly for all kid controls. The controls in
the control tree are made. This event handling can be taken care of by over-burdening the OnLoad
strategy or making a Page_Load handler.

- LoadComplete
The loading procedure is finished, control event handlers are run, and page validation happens. This
event handling can be taken care of by over-burdening the OnLoadComplete strategy or making a
Page_LoadComplete handler

- PreRender
The PreRender event happens just before the output is rendered. By taking care of this event, pages
and controls can perform any upgrades before the output is rendered.

- PreRenderComplete
As the PreRender event is repeatedly let go for all type of controls, this event guarantees the
consummation of the pre-rendering stage.

- SaveStateComplete
State of control on the page is spared. Personalization, control state and view state data is spared. The
HTML markup is created. This stage can be taken care of by abrogating the Render technique or
making a Page_Render handler.

- UnLoad
The UnLoad stage is the last period of the page life cycle. It raises the UnLoad event for all
controls repeatedly and in conclusion for the page itself. Last cleanup is done and all assets and
references, for example, database associations, are liberated. This event handling can be taken care of
by changing the OnUnLoad strategy or making a Page_UnLoad handler.

For .NET training and placement reviews, please do visit CRB Tech Reviews.


Here Are Few Tips on Asp.Net Life Cycle

Top 5 Standards To Follow While Coding In VB .Net