15 August, 2011

The ASP.NET Application Life Cycle

It is important to have a solid understanding of the life cycle of an ASP.NET application when you are working with server-side state management. This life cycle defines how the application server starts and stops your application, isolates it from other applications, and executes
your code.

In production environments, ASP.NET applications run within a web server. The web serveris usually Internet Information Services (IIS) hosted on a recent version of Windows Server, such as Windows Server 2008 R2, which includes IIS 7.5. The following stages constitute the application life cycle of an ASP.NET application running on IIS 7.5:



1. A user first makes a request for a page in your site.

2. The request is routed to the processing pipeline, which forwards it to the ASP.NET
runtime.

3. The ASP.NET runtime creates an instance of the ApplicationManager class. The
ApplicationManager instance represents the Microsoft .NET Framework domain that
will be used to execute requests for your application. An application domain
isolates global variables from other applications and allows each application to
Load and unload separately as required.

4. After the application domain has been created, an instance of the
HostingEnvironment class is created. This class provides access to items inside
the hosting environment, such as directory folders.

5. ASP.NET creates instances of the core objects that will be used to process the
request.This includes HttpContext, HttpRequest, and HttpResponse objects.

6. ASP.NET creates an instance of the HttpApplication class (or an instance is
reused). This class is also the base class for a site’s Global.asax file. You can
use this class to trap events that happen when your application starts or stops.
When ASP.NET creates an instance of HttpApplication, it also creates the modules
configured for the application, such as the SessionStateModule.

7. Finally, ASP.NET processes requests through the HttpApplication pipeline. This
pipeline also includes a set of events for validating requests, mapping URLs,
accessing the cache,and more.




No comments:

Post a Comment