A full understanding of the HTTP runtime is essential to making sense of internal ASP.NET processes and therefore possible extensions. For example, ASP.NET AJAX is a set of extensions bolted on the HTTP runtime and fully integrated with it. Let's briefly recap the key elements of the ASP.NET runtime.
A full understanding of the HTTP runtime is essential to making sense of internal ASP.NET processes and therefore possible extensions. For example, ASP.NET AJAX is a set of extensions bolted on the HTTP runtime and fully integrated with it. Let's briefly recap the key elements of the ASP.NET runtime.
When an ASP.NET request hits the Web server, it is forwarded to the worker process that hosts and runs the application. The specifics of the worker process change with the version of IIS installed and the selected process model. In a scenario with Windows 2000 Server as the server operating system, the worker process is aspnet_wp.exe, an executable installed with ASP.NET. With Windows 2003 Server and Windows Vista, the worker process is a constituent part of the system and is named w3wp.exe. Windows Vista is a user system, and it is not designed to run server applications. But it is equipped with the newest version of IIS. IIS 7.0 in Windows Vista is feature complete, and aside from parameters such as supported number of connections and users, is equivalent to the version of IIS 7.0 that will ship with the upcoming Windows 2008 Server (codenamed Windows Longhorn Server).
The worker process initializes the Common Language Runtime and passes any incoming ASP.NET requests to the so-called "HTTP pipeline." The detailed steps of how this happens are specific of the worker process and the process model in use.
The HTTP pipeline is a fully extensible chain of managed objects that works according to the classic concept of a pipeline. The original HTTP payload enters in one end of the pipeline and, at the end produces some markup code for the browser. The entry point in this pipeline is the HttpRuntime class. The ASP.NET worker process activates the HTTP pipeline by creating a new instance of the HttpRuntime class and then calling its ProcessRequest method.
Upon creation, the HttpRuntime object initializes a number of internal objects that will carry out the page request. Helper objects include the cache manager and the file system monitor used to detect changes in the source files of the application. In addition, the HttpRuntime object creates a new context for the request and initializes a specialized text writer object in which the markup code will be accumulated. A context is given by an instance of the HttpContext class, which encapsulates all HTTP-specific information about the request. This HttpContext object accompanies the request for its whole lifetime.
The runtime's next step is finding out a Web application object capable of processing the request. This object is an instance of a class derived from HttpApplication. In most cases, the class is dynamically built from the contents of the application's global.asax file. This object is responsible for locating the HTTP handler component for the request-that is the class that will physically produce the response for the browser. A HTTP handler is a class that implements the IHttpHandler interface; the System.Web.UI.Page class is the most complex handler of the whole ASP.NET platform.
The ASP.NET developer is responsible for writing the page class-both markup and code-behind logic-and this closes the circle. The output for the page is returned to HttpRuntime and from there served to the user.