| ASP.NET Application Phases |
| |
| Application Life Cycle |
| |
| The life cycle of an application in ASP.NET include many stages to process the web page. Inside ASP.NET, several processing steps must occur for an ASP.NET application to be initialized and process requests. These steps are given below: |
| |
1. Users request for an application resource.
2. First request received by ASP.NET.
3. Objects created for each request by ASP.NET.
4. Assignment of an HttpApplication object to the request
5. Request processed by the HttpApplication pipeline. |
| |
| The above mention steps for the life cycle of an application are explained below: |
| |
| A request sent by a browser to the Web server (for ASP.NET applications, typically IIS) starts the life cycle of an ASP.NET application. ASP.NET is an ISAPI extension under the Web server. When a Web server receives a request, it inspects the file name extension of the requested file, determines which ISAPI extension should handle the request, and then passes the request to the appropriate ISAPI extension. ASP.NET handles file name extensions that have been mapped to it, such as .aspx, .ascx, .ashx, and .asmx. |
| |
| On receiving first request for any resource in an application, a class named ApplicationManager creates an application domain in the ASP.NET. Application domains provide separation between applications for global variables and allow each application to be unloaded separately. Within an application domain, an instance of the class named HostingEnvironment is created, which provides access to information about the application such as the name of the folder where the application is stored. |
| |
| ASP.NET creates and initializes core objects such as HttpContext, HttpRequest, and HttpResponse when the application domain has been created and the HostingEnvironment object instantiated. |
| |
| After the initialization of the entire core application objects, the application is started by creating an instance of the HttpApplication class. If the application has a Global.asax file, ASP.NET instead creates an instance of the Global.asax class that is derived from the HttpApplication class and uses the derived class to represent the application. Then request is processed by the HttpApplication pipeline. The HttpApplication pipeline includes various events are executed by the HttpApplication class while the request is processed. |
| |
| During life cycle of an application, the application raises events that can be handled and calls particular methods that you can override. To handle application events or methods, you can create a file named Global.asax in the root directory of your application. |
| |
|
| |