In this post, we are exploring more about ASP.NET life cycle. ASP.NET life cycle includes the following processes:
ASP.NET processes pages to generate dynamic output
The application and its pages are instantiated and processed
ASP.NET compiles the pages dynamically
1) ASP.NET Application Life Cycle
The application life cycle has the following stages:
User makes a request for accessing application resource, a page. The browser sends this request to the web server.
A unified pipeline receives the first request and the following events take place:
o An object of the class Application Manager is created.
o An object of the class Hosting Environment is created to provide information regarding the resources.
o Top level items in the application are compiled.
Response objects are created. The application objects such as HttpContext, HttpRequest and HttpResponse are created and initialized.
An instance of the HttpApplication object is created and assigned to the request.
The request is processed by the HttpApplication class. Different events are raised by this class for processing request.
2) ASP.NET Page Life Cycle
When a page is requested, it is loaded into the server memory, processed, and sent to the browser. Then
it is unloaded from the memory. At each of these steps, methods and events are available, which could
be overridden according to the need of the application.
The Page class creates a hierarchical tree of all the controls on the page. All the components on the page,
except the directives, are part of this control tree. We can see the control tree by adding trace= "true"
to the page directive. Click Here For More Info
The page life cycle phases are
Initialization
Instantiation of the controls on the page
Restoration and maintenance of the state
Execution of the event handler codes
Page rendering
Understanding the page cycle helps in writing codes for making certain things happen at any stage of the
page life cycle. It also helps in writing custom controls and initializing them at the right time,
populate their properties with view-state data and run control behavior code.
No comments:
Post a Comment
Please do not enter any spam link in the comment box.