This article focuses on the different ways the Web requests are handled by the 3 major IIS versions.
Content of this article
- IIS 5.x and ASP.
- IIS 6.0 and ASP.
- IIS 7.0 and ASP.
- ASP. NET Integration
IIS 5.x and ASP.
How IIS 5.x handles requests that are based on ASP. NET resources such as. aspx,. asmx, and so on.
IIS 5.x runs in process Inetinfo.exe, which hosts a Windows service named World Wide Web Publishing Service (W3SVC). W3SVC main features include listening for HTTP requests, worker processes, and configuration management (by loading related configuration information from metabase Metabase).
Figure 1 IIS 5.x and ASP.
When an HTTP request is detected, IIS first determines whether the request is a static resource (such as. html,. img,. txt,. xml, and so on), and, if it is, returns the contents of the file directly as an HTTP response, otherwise, if it is a dynamic resource such as. aspx,. asp,. PHP, and so on), the appropriate ISAPI dynamic-link library is found from the IIS script map (the script map) by extension.
ISAPI (Internet Server application Programming Interface) is a set of local Win32 APIs that are a link between IIS and other dynamic WEB applications or platforms. The ISAPI definition is in a dynamic-link library (DLL) file, and the corresponding DLL file for the ASP. NET ISAPI is Aspnet_isapi.dll. ISAPI supports ISAPI extensions (ISAPI Extension) and ISAPI filtering (ISAPI filter), which is the interface that really handles HTTP requests, which can view, modify, forward, or reject requests before HTTP requests are actually processed, such as IIS can take advantage The ISAPI filter makes request validation.
If you are requesting an ASP. NET-based resource type, such as. aspx,. asmx, and so on, Aspnet_isapi.dll will be loaded, and ASP. NET Extension will create an ASP. NET worker process (if the process is not started). For IIS 5.x, the worker process is aspnet_wp.exe. The IIS process communicates with the worker process through a named pipe (Named Pipes).
During the initialization of a worker process, the. NET CLR is loaded and a managed environment is built. For a Web app's initial request, the CLR creates an application domain for it (application domain). In the application domain, the HTTP runtime (HTTP runtime) is loaded and the appropriate app is created. All Web apps hosted in IIS 5.x run in different application domains in the same worker process (aspnet_wp.exe).
IIS 6.0 and ASP.
IIS 5.x has at least two deficiencies:
- The 1,ISAPI dynamic link library is loaded into the Inetinfo.exe process, which is a typical cross-process communication with the worker process aspnet_wp.exe, despite the use of named pipes, but there are still performance bottlenecks;
- 2, all Web apps run in different application domains in the same process (aspnet_wp.exe). Application-domain-based isolation does not fundamentally address the impact of an application on another application.
To solve the first problem, IIS 6.0 loads the ISAPI dynamic link library directly into the worker process;
To solve the second problem, introduce the application pool (application) mechanism. You can create an application pool for one or more Web apps. Because each application pool corresponds to a separate worker process, it provides a process-based isolation level for WEB apps running in different application pools. The IIS 6.0 worker process is named W3wp.exe.
In addition to the above two improvements, IIS 6.0 has some commendable points. One of the most important is the creation of a named HTTP. SYS's HTTP listener. HTTP. SYS runs in the form of a driver in Windows kernel mode (kernel mode), which is part of the TCP/IP network subsystem of Windows 2003, and structurally it belongs to a network driver on top of TCP.
Strictly speaking, HTTP. SYS is not part of the IIS category, so HTTP. SYS's configuration information is not saved in IIS Metabase, but is defined in the registry. HTTP. The benefits of SYS are as follows:
- 1, continuous monitoring. Because of HTTP. SYS is a network driver that is always running and responds to the user's HTTP requests in a timely manner;
- 2, better stability. HTTP. SYS runs in the operating system kernel mode and does not execute any user code, so itself is not affected by WEB applications, worker processes, and IIS processes;
- 3, the data cache in kernel mode. If a resource is requested frequently, HTTP. SYS will cache the response memory, and the cached content can respond directly to subsequent requests. Because this is a kernel-based cache, there is no kernel-mode and user-mode switching, and the response speed will be greatly improved.
Figure 2 illustrates the structure of IIS and the process of handling HTTP requests. Unlike IIS 5.x, W3SVC is detached from the Inetinfo.exe process (for IIS 6.0来, Inetinfo.exe can basically be considered a purely IIS management process) and run in another process Svchost.exe. The basic function of W3SVC has not changed, but has made the corresponding improvement in the realization of the function. As with IIS 5.x, Metabase still exists in the Inetinfo.exe process.
Figure 2 IIS 6.0 and ASP.
When HTTP. sys listens to the user, it sends it out to W3svc,w3svc to parse out the requested URL, and obtains the target application based on the mapping between the URL obtained from Metabase and the Web app, and further obtains the application pool or worker process that the target application is running. If the worker process does not exist (it has not been created or reclaimed), a new worker process is created for the request. The corresponding ISAPI dynamic-link library is loaded during the process initialization of the worker. For ASP. NET application, the ISAPI being loaded is aspnet_iaspi.dll. The ASP. NET ISAPI is responsible for the loading of the CLR, the creation of the application domain, and the initialization of the Web application.
IIS 7.0 and ASP.
IIS 7.0 also improved on the request monitoring and distribution mechanism. The main embodiment is the introduction of the Windows Process Activation service (Windows Processes Activation Service,was), which diverted some of the functionality of the original IIS 6.0 w3svc to was. There are three main features for IIS 6.0 W3SVC:
- 1,http request received. Receiving HTTP requests that are heard by the. Sys;
- 2, configuration management. Load configuration information from metabase to configure related components;
- 3, Process management. Create, recycle, and monitor worker processes.
IIS 7.0 implements the latter two features into was. was introduced for IIS 7.0 to provide support for non-HTTP protocols. was abstracted different protocol listeners, such as TCP listeners, named pipe listeners, and MSMQ listeners, through the Listener adapter interface (Listener Adapter Interface).
Figure 3 shows the overall architecture of IIS 7.0 and the entire request processing process. Either the HTTP request received from W3SVC or the request received through the WCF listener adapter will eventually be passed to was. Created if the corresponding worker process (or application pool) has not been created; otherwise, the request is distributed to the corresponding worker process for subsequent processing. Was in the process of request processing, through the built-in configuration management module to load the relevant configuration information, and to configure the relevant information. Unlike the Metabase-based configuration information store for IIS 5.x and IIS 6.0, most IIS 7.0 stores configuration information as an XML file, with the basic configuration stored in applicationhost.config.
Figure 3 IIS 7.0 and ASP.
ASP. NET Integration
IIS 5.x and IIS 6.0,iis and ASP. NET are two separate pipelines. Within their scope, they have their own set of mechanisms to handle HTTP requests. Two pipelines are connected through an ISAPI. IIS is the first to pre-process HTTP requests, such as authentication, to distribute requests to the ASP. When ASP. NET finishes processing the HTTP request, the processed results are returned to Iis,iis for post-processing, such as logging, compression, and so on, resulting in an HTTP response.
However, there are some limitations and deficiencies in the dual-pipeline design of IIS 5.x and IIS 6.0.
To do this, IIS 7.0 implements the integration of both.
IIS 5.x/6.0/7.0 and ASP.