The life of an ASP.NET Request
Published: 07 Sep 2002
Unedited - Community Contributed
Although it may not seem like it, the way that ASP.NET processes your HTTP Request and returns your web page is a lot more complex than it may seem. This article will look at the HTTP Pipeline in ASP.NET and the lead up to your rendered pages.
by . .
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 19817/ 42



Although it may seem like it, the way that ASP.NET processes your HTTP Request and returns your web page is a lot more complex than it may seem. The HTTP Pipeline in ASP.NET is a large (but streamlined) process where requests go in and pages come out. In other articles I have looked at the Page object and the role that it plays in providing content, but this article is going to look at the processes before it.

The Web Server

The Web Server - IIS

The first thing that happens to your request is IIS come in.
NB. I am aware that other web servers are beginning to support ASP.NET. But they will be totally ignored here.

The request comes into IIS and it does several things to it before it is sent to the ASP.NET process.

This diagram shows you that IIS does it's own processing of the request (to determine if it's valid etc.) and then looks for an ISAPI Filter for it. As IIS 5 and below only support ISAPI Filters as a means of handling the request, ASP.NET has it's own ISAPI Filter (called aspnet_isapi.dll). All this filter does is pass on the request to the ASP.NET Worker Process.

Of course, there is a lot of other stuff that goes on in there, but this is just the basics.

The ASP.NET Worker Process

ASP.NET Worker Process

Now that the ASP.NET Worker Process has the request, it starts using .NET to process it (and here is where you can come in).

First, the request is passed to an HTTPRuntime object which is the start of the Pipeline (which is the above diagram). The HTTPRuntime examines the request and determines things like where it's going . It then creates an HTTPApplication object to process the request. The HTTPApplication essentially passes the request to a series of HTTPModule objects which simply examine and modify the request as necessary (Injection Point #1). Then the HTTPApplication object creates and passes the request (which is in an HTTPContext form) to the HTTPHandlers.

An HTTPHandler is anything that implements the IHTTPHandler interface. For example, the Page class implements IHTTPHandler and in your machine.config file, it says that all requests for .aspx files are passes to the PageHandlerFactory (which in time turns out your Page). This is Injection Point #2.

Injection Points

Injection Point #1 - HTTP Modules

HTTPModules are classes that examine and modify HTTP Requests as they come through. When you register a new one for your application you can get it to do stuff. For example, you can use set event handlers for it's events like BeginRequest and EndRequest to take a look a system resources before and after the request has passed or measure the time it takes to process a request.

Also, because you get passed an HTTPApplication object, you can look at and modify objects that you are already used to like the Response and Request objects.

See the Related Articles for more information on HTTPModules.

Injection Point #2 - HTTP Handlers

Not all request are processed by all of the HTTPHandlers that you have defined. Usually you define a new extention in IIS that gets passed to the ASP.NET ISAPI Filter and then handle that specific extension in your handler or you can use existing ones.

You get passed in an HTTPContext object and then can use that to modify the request and response. HTTP Handlers can also be deployed as files with the .ASHX extension which makes them easier to deploy.

The uses of an HTTPHandler may include checking the client browser to determine if they can support something and then terminating the request if needed. This is easier than coding this into the aspx file because this way it just takes one line of code in web.config.

See the Related Articles for more information on HTTPHandlers.



With all of these processes taking place, we've forgotten about Global.asax. You may think - "What about global.asax?" Well, it too is an important part of the ASP.NET Processing Processes. Global.asax is actually the file which handles events coming from the HTTPApplication object as well as events in HTTPModules that you have. This makes it easier to use than an HTTPModule if you only need the functionality provided by it (instead of the whole HTTPModule).

See the Related Articles for more information on Global.asax.


Well, this article has gone over the general processing of an HTTP Request and how you an intercept and modify that request. There are a few articles in the Related Articles that a worth a look at if you want to know more about anything in there (as some of the stuff was also explained loosely for simplicity).

User Comments

Title: very useful   
Name: Kaja Moinudeen
Date: 2004-09-29 3:12:44 AM
This articles gives a very good picture ofthe processes.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-02-25 10:49:42 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search