What is ASP.Net Lifecycle?
When an ASP.Net program is launched, a series of steps are performed. Such a sequence of
Levels make up the lifecycle of the application.
Object creation – The next stage is the creation of the HttpContext, HttpRequest & HttpResponse by the webserver. The HTTPContext is just the container for the object’s HttpRequest and HttpResponse. The object HttpRequest contains information on the current request, including information about cookies and app. The target of the HTTPResponse includes the response sent to the user.
What is ASP.Net Page Lifecycle?
When calling an ASP.Net page, it goes through a specific lifecycle. This is done before the client receives a reply. There are a series of steps for processing an ASP.Net page that is followed.
1. Page Request- When the client requests the server for the first time for a page. The server checks whether requested for the first time when the site is submitted. If so, the website must be compiled, the answer must be parsed, and sent to the user. If the page is not requested for the first time, the cache will be checked to see if there is any page output. If so, the client will receive the response.
2. Page Start – Two objects are generated during this process, known as the Request and Answer set. The Request object is used to keep all the data that was sent when the page was requested. The Response object is used to hold back the data that is sent back to the user.
3. Page Load:-This is when all the default values are fully loaded on the server. So if a textbox has a default value, the value will be loaded during the load time.
4. Page Initialization: – All controls on a web page are initialized during this process, so if there are any tags like a textbox or other web-type control, they are initialized.
5. Verification: – Sometimes, some type of verification can be set. There may be a validation, for example, which states a list box should have a specific set of values. If the condition is incorrect, a loading error will occur.
6. Postback event handling: –If the same site is loaded again, this event will be triggered. In response to an earlier event, this happens. Sometimes there may be a situation where a user clicks on the page’s submit button. The same page is shown again in this case. In such a case, the handler of the Postback event is called.
7. Page Rendering: –This occurs just before the user receives all the response information. All information on the form will be saved, and the result will be sent as a complete web page to the user.
8. Unload: –There is no need to keep the ASP.net web form objects in memory once the page output is sent to the user. So the process of unloading involves removing all unwanted objects from the memory.