IIS 5.x/6.0/7.0 and ASP.

Source: Internet
Author: User
Tags metabase

Original: IIS 5.x/6.0/7.0 and ASP.

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 for ASP. NET resources such as. aspx,. asmx, and so on.

IIS 5.x runs in process Inetinfo.exe, which hosts a Windows service called 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).

The resource mappings are stored in the IIS metabase. At installation time, ASP. NET modifies IIS metabase to ensure that Aspnet_isapi.dll is able to handle all resources identified by extension.

Figure 1 IIS 5.x and ASP.

When an HTTP request to a resource arrives, IIS first confirms the resource type based on the extension. For static resources (like, text files, HTML pages, ASP pages without scripts, etc.), do not use external modules, are processed directly by IIS, directly return the content in the form of an HTTP response, otherwise, dynamic resources (such as. aspx,. ASP,. PHP, etc.), by extension from the IIS The appropriate ISAPI dynamic-link library is found in the script map.

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.

The ISAPI extension does not process. aspx files, but rather acts as a scheduler. It collects all relevant information about the called URL and the underlying resource, and then forwards the request to the ASP. NET worker process.

If the request is an ASP. asp is processed by the Asp.dll ISAPI extension, the. aspx is assigned to the ISAPI extension of Aspnet_isapi.dll, and the ASP is created by ASP. NET worker process (if the process is not started). For IIS 5.x, the worker process is aspnet_wp.exe. The IIS process (Aspnet_isapi.dll) communicates with the worker process (aspnet_wp.exe) through a named pipe (Named Pipes).

The ASP. NET worker process represents an ASP. Win32 unmanaged executable file named Aspnet_wp.exe that hosts the. NET Common Language Runtime (CLR). The ASP. NET worker process activates the HTTP pipeline, which actually processes the page request. An HTTP pipeline is a collection of. NET Framework classes that is responsible for compiling page assemblies and instantiating related page classes.

During worker process initialization, 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.

Figure 3 How to handle WEB applications in IIS 6.0

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 4 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 4 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.