BRIEF EXPLANATION OF ASP.NET LIFE CYCLE AND ASP.NET PAGE LIFE CYCLE

ASP.NET LIFE CYCLE AND ASP.NET PAGE LIFE CYCLE

ASP.Net Lifecycle


BRIEF EXPLANATION OF ASP.NET LIFE CYCLE AND ASP.NET PAGE LIFE CYCLE


When an ASP.Net application is created, there is a series of steps, this series is the life cycle of the application.


  • Application Start: - The life cycle of an ASP.NET application starts when a request is made by the user. This request is for a web server by an ASP.Net application. This process starts when the user visits the home page for the first time. Meanwhile, the application starts method starts, which is executed by the webserver. Typically, in this method, all global variables are set to their default values.
  • Object creation: - Next step is to create HttpContext, HttpRequest & HttpResponse by web server. HttpContext is the container for HttpRequest and HttpResponse objects only. The HttpRequest object stores information about current requests, including cookies and browser information. The HttpResponse object also contains the response sent to the client.
  • HttpApplication creation: - This object is created by the webserver. This object processes the request sent to the application. For example, suppose we have 2 web applications. One is a shopping cart application, and the other is a news website, then for each application, HttpApplication objects will be created. Any request on each website is processed by HttpApplication respectively.
  • Dispose of: - In this event, all the objects created in the application are deleted.
  • Application End: - This is the last part of the application. In this part, the application is eventually unloaded from memory.

ASP.Net Page Lifecycle


When ASP.NET Web Page Run happens, it goes through one of its Life Cycles, in which it performs a series of several processing steps. Initialization of Web Page is done under this Series, if there is a control on the Web Page, then the initialization of those Controls takes place, the State is Restore and Maintained, the Event Handler Codes are run and the generated Response is generated. Render is done by Web Browser.


Therefore, understanding the life cycle of a page proves very useful for us especially when we are developing custom controls for our web page. Because in that case, it is necessary to initialize the controls correctly, populate the properties of the control with view-state data, and perform the tasks like running the control's Behavior in the Appropriate Stage of the Page Life Cycle.


Generally, the life-cycle of our custom control is also based on the life cycle of our web page, so the life-cycle of the control is controlled based on the life-cycle of the page.


BRIEF EXPLANATION OF ASP.NET LIFE CYCLE AND ASP.NET PAGE LIFE CYCLE

Page Request Stage


Before a page's life-cycle starts, a Page Request is performed, which represents the request made by a user to a Web Page. During this stage, the ASP.NET Web Server detects that the web page for which the user has performed the request will have to be compiled by parsing the web page or the web page already has a Cached Version Exist, Which can be used to generate Response.


Page Start Stage


In this state of the life-cycle of a web page, properties like Request and Response of the page are set. Also in this stage, it is ascertained that the page for which the request is made is a PostBack Request or a New Request and the IsPostBack Property is checked to detect this. Also, Page your UICulture Property is also set at this stage.


Page initialization Stage


Initialization of the page occurs in this stage of the life-cycle of a page, during which the initialization of the various controls located on the page takes place and their UniqueID Property is set. Also, if a Master Page or a Theme is specified, then the Master Page or Theme is also applied during this stage of the Life-Cycle of the Web Page. While the Current Request is a PostBack Request, the PostBack Data would not have been loaded yet. Also, Control Property Values ​​are not restored from their View-State Values.


Page Load Stage


This Stage of the Life-Cycle of a Page contains Page Load. Whereas if the current request is a PostBack Request then the Control, Property Values ​​are restored in the same Stage from the Values ​​of their View-State.


Page Postback Event Handling Stage


If the current request is a PostBack Request then the Event Handlers of the Control call in this Stage of the Life-Cycle of a Page, followed by the Validate () Methods Call of all Validator Controls, which is the IsValid Property of all the individual Controls in the Page. Let's set it up.


Page Rendering Stage


Before rendering in this stage of the Life-Cycle of a page, the View-State is saved for the current page and all its controls. During this stage, Page calls the Render () method for each control and provides a Text Writer which writes its Output into the OutputStream Object of our Page's Response Property.


Page Unload Stage


In this stage of the Life-Cycle of a page, our page has been completely rendered, has been sent to the client, and is ready to be destroyed. In this stage, the properties of Page's Response and Request are unloaded and cleaned, that is, the process of Garbage Collection is executed by the .NET Platform.


In this way an ASP.NET Web Page goes through several Stages in its Life Cycle and performs an Event Trigger at the end of each Stage, representing the End of that Stage. For these events, we write Program Logic Codes in Code-Behind Class according to our needs

AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST