IIS 7.0 and ASP. NET

Source: Internet
Author: User
Tags msmq metabase
IIS 7.0 and ASP. NET

IIS 7.0 has also improved the request listening and distribution mechanism, mainly because of the introduction of Windows Process activation Service (was, some functions carried by the original (IIS 6.0) W3SVC are distributed to was. Through the above introduction, we know that for IIS 6.0, W3SVC mainly carries three functions.

HTTP request receiving: receives the HTTP request listened by HTTP. sys.

Configuration Management: load configuration information from metabase to configure related components.

Process Management: creates, recycles, and monitors work processes.

IIS 7.0 implements the last two sets of functions into was, and the tasks for receiving HTTP requests are still on the w3svc header. The introduction of was provides non-HTTP support for IIS 7.0. Was abstracts different protocol listeners through the listener adapter interface. Specifically, besides the network-driven HTTP. in addition to HTTP request listening, sys also provides TCP listeners, named pipe listeners, and MSMQ listeners to support TCP, named pipes, and MSMQ transmission protocols.

Compared with the three listeners, they provide adaptation between listeners and listener adapter interfaces in was. In this sense, W3SVC in IIS 7.0 serves as a listening adapter for HTTP. sys. These three non-HTTP listeners and listener configurations are defined in the program set smhost.exe. You can find them in the directory % WinDir % \ microsoft. net \ framework \ V3.0 \ Windows Communication Foundation.

These three listeners and listening adapters provided by WCF are ultimately reflected in the form of Windows Services. Although they are defined in a set of programs, we can still start, terminate, and configure them separately through the service work manager. Smhost.exe provides four important Windows Services.

Nettcpportsharing: Provides TCP port sharing for WCF. For the application of Port Sharing in WCF, I will provide a detailed introduction to this article titled "WCF comprehensive analysis" (Volume 1.

Nettcpactivator: Provides TCP-based activation requests for was, including TCP listeners and corresponding listening adapters.

Netpipeactivator: provides a named pipeline listener and corresponding listener adapter for was.

Netmsmqactivator: Provides MSMQ-based activation requests for was, including MSMQ listeners and corresponding listening adapters.

Figure 1-7 shows the preceding four Windows Services in the Service Control Manager.

 

Figure 1-7 define Windows Service in smhost.exe

Figure 1-8 shows the overall structure of IIS 7.0 and the entire request processing process. Whether it is an HTTP request received from W3SVC or a request received through the listener adapter provided by WCF, it will eventually be passed to was. If the corresponding Worker Process (or application pool) has not been created, create it. Otherwise, the request is distributed to the corresponding Worker Process for subsequent processing. During request processing, was loads related configuration information through the built-in configuration management module and configures related components. And IIS 5. different from the metabase-based configuration information storage in IIS 6.0, most of the configuration information in IIS 7.0 is stored in xml configuration files, and the basic configuration is stored in applicationhost. config.

 

Figure 1-8 IIS 7.0 and ASP. NET

ASP. NET Integration

From the introduction to IIS 5.x and IIS 6.0, we can easily find that IIS and ASP. NET are two independent pipelines ). Within their respective jurisdictions, they each have their own set of mechanisms to process HTTP requests. The two pipelines are connected through ISAPI. IIS is the first barrier. When necessary preliminary processing (such as identity verification) is performed on HTTP requests, use ISAPI to distribute requests to ASP.. Net pipeline. When ASP. when processing HTTP requests within the MPs queue, the processed results are returned to IIS, and IIS performs post-processing (such as log record and compression) on the requests ), finally, an HTTP response is generated. Figure 1-9 shows the IIS
6.0 bridging relationship with ASP. NET.

 

Figure 1-9 IIS 6.0 and ASP. NET dual-Pipeline Design

From another perspective, IIS runs in an unmanaged environment, while ASP. NET pipelines are hosted, and ISAPI is the link between an unmanaged environment and a hosted environment. IIS 5.x and IIS 6.0 isolate the two pipelines by at least some of the following limitations and limitations:

Repeated execution of the same operation: there are repeated operations between IIS and ASP. NET, such as identity authentication.

Dynamic files and static files are processed differently: because they are only Based on ASP. NET Dynamic files (such. aspx ,. asmx ,. (SVC. net isapiinto the asp.netpipeline, and for a few static files (such as .html ,. XML ,. IMG) requests are directly responded by IIS, so ASP. some functions in the. NET pipeline cannot be used for these static file-based requests. For example, if we want to apply the forms authentication to image file-based requests, we cannot.

Difficult to expand IIS: IIS extensions are basically reflected in custom isapis, but this is not an easy task for most people. Because ISAPI is a Win32-based unmanaged API, it is not an application-oriented programming interface. What we usually want is to extend IIS by hosting code like defining ASP. NET's httpmodule and httphandler.

For IIS on Windows, Asp. net is undoubtedly a first-class citizen. They should not be "water is not a river", but "you have me, I have you". Therefore, they are integrated in IIS 7.0, the following benefits can be achieved through integration.

You can define the IIS module by using native code or managed code. These IIS modules are registered into IIS to form a common request processing pipeline. The pipeline composed of these IIS modules can process all requests, regardless of the resource type of the request. For example, you can apply the forms authentication provided by formsauthenticationmodule to requests based on. aspx, CGI, and static files.

Apply some powerful functions provided by ASP. NET to areas that are hard to match. For example, place the URL rewriting function of ASP. NET before authentication.

Implement, configure, detect, and support some server features in the same way, such as module, Handler ing, and custom error configuration.

Figure 1-10 shows the structure of the entire request processing pipeline of IIS in ASP. NET integration mode. As you can see, the hosted components provided by ASP. NET can be directly applied to the IIS pipeline.

 

Figure 1-10 IIS 7.0 and ASP. NET integrated Pipeline Design

 

 

 

 

 

 

This article is excerpted from ASP. net mvc 4 Framework secrets

Jiang Jinnan

Published by Electronic Industry Publishing House

Related Article

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.