What happened before MVC series (1): Entering the CLR

Source: Internet
Author: User
Tags metabase

MVC before the point of the series, is the author in the early 2012 to read the MVC3 source when the collation, the main story is from the HTTP request to enter the Mvchandler before the content, including the original, translation, reprint, collation and other types of articles, of course, also refer to the blog Park a number of articles, Daniel Thank you for this, there is time to put it out, hope to be useful to everyone.

Main content

This article explains how the server takes the HTTP request request and how it enters the. Net CLR for further action.

As we all know, IIS must accept the request before it has a chance to enter the CLR, but is not aware of how requests are routed from the Web server to the ASP. Because of the different versions of IIS, the way in which the CLR is entered may vary, and this section will explain the way in which the three versions of IIS5/6/7 are entered, and the understanding of these underlying mechanisms allows us to have a deeper understanding of ASP.

the ASP. NET request processing process for IIS 5

The IIS5 core feature is that IIS is allowed on a process called InetInfo.exe, so both the ASPX page and the HTML page are processed through this process, where the ASPX page extension is mapped to the ASPNET ISAPI. DLL, so if the page is ASPX, the ASPNET ISAPI. DLL creates aspnet_wp this worker Process and loads the CLR at initialization time, so this is a managed environment.

The points to note are:

  1. The same server can only run one aspnet_wp process, which means that all ASP. NET Web application are in the same worker process, but it does not mean that they share the same context and database, ASP. NET has an AppDomain concept, each site or virtual directory corresponds to a separate AppDomain, each AppDomain is isolated, has its own separate context context, so security is no problem, So our conclusion is that the ASP is to continue the AppDomain, not process-based.
  2. The ASP. NET ISAPI is not only responsible for creating the aspnet_wp Worker process, but also for monitoring the process, if the aspnet_wp performance is detected to a lower limit, the ASP. NET ISAPI will end the process, When the request comes in, the ASP. NET ISAPI will recreate the new aspnet_wp Worker Process.
  3. Because IIS and application run in their respective processes, communication between them must adopt a specific communication mechanism. Due to the communication between the different processes of the machine (local interprocess communications), in performance, they use a communication mechanism based on named pipe. The communication between the ASP. NET ISAPI and worker process is implemented through a set of pipes between them. Also in performance, the ASP. NET ISAPI asynchronously passes the request to worker process and obtains Response, but the worker process is synchronized to the ASP. Some Server-based variables.
the ASP. NET request processing process for IIS 6

IIS6 and IIS5 have 3 very different places: Accept requests (HTTP. sys), application pools (application pool), W3wp.exe Worker Process.

In IIS5, the InetInfo.exe attachment listens and processes requests (request), but in IIS6, the server receives the request via a new component, HTTP. sys.

When HTTP. SYS receives the request, it will see which application pool the application based on the request belongs to, based on Metabase in IIS, and if the application pool does not exist, it is created. Otherwise, the request is sent directly to the queue corresponding to the application Pool.

Each application Pool corresponds to a worker Process:w3wp.exe. The mapping of application Pool and worker process are maintained in IIS Metabase. The WAS (Web Administrative service) passes the request that exists in a application Pool queue to the corresponding worker process (if not, based on such a mapping). Create a process like this). When the worker process is initialized, the ASP. Isapi,asp.net ISAPI loads the CLR.

Note: One difference between IIS5 and IIS6 is that the ASP. NET ISAPI in IIS5 creates the aspnet_wp Worker Process, which then loads the CLR, but in IIS6 is w3wp after the application pool's map relationship runs To load the ASP. NET ISAPI and then load the CLR.

the ASP. NET request processing process for IIS 7

Step 1 to 6, is the processing application start, after the start, you do not need to go this step again, the 8 steps are as follows:

    1. http.sys Listen intercept client request started processing.
    2. http.sys contact was for information about configuration information.
    3. was requests configuration information from the configuration store. ApplicationHost.config.
    4. WWW Service accepts configuration information, which is similar to application pool configuration information, site configuration information, and so on.
    5. WWW service uses configuration information to configure the HTTP. SYS processing policy.
    6. was opens application Worker Process for the application pool (w3wp pool) corresponding to this request.
    7. w3wp Worker process is processed, and response is returned to HTTP. Sys.
    8. The client accepts response content.

What if the W3WP.exe process is done?? Depending on the application pool managed pipeline mode of IIS 7, IIS7 currently has 2 modes: Classic mode and Integrated mode. The two modes of processing are not the same, see the following differences:

IIS7 Classic Mode:

IIS7 's Classic mode and IIS6 are handled the same way, after the user sends the HTTP request request, IIS will process, IIS will filter according to the HTTP request type, if the HTML static Web page is handled by IIS itself, if not, Assign to the respective IIS ISAPI extension for content types that are specific to the requirements, and if the required content type is ASP, assign to the IIS ISAPI extension that is responsible for processing ASP. Isapi.dll, and then into the CLR.

IIS7 Integrated Mode:

IIS7 Integration mode is a great improvement that has preloaded the CLR (not on the IIS version before relying on the Aspnet_ispai. DLL), which means that all HTTP request requests are processed by ASP (including HTML, PHP, etc.), and because many of the features of ASP. asp, PHP, or static HTML Web pages, etc. You can also use ASP. NET 2.0 features such as the Forms authentication (forms authentication) or output cache (outputs caching) (but you need to modify the settings for IIS 7), as well as IIS 7 allows you to develop and join your own ASP. module, it is easier for ASP. NET Web page developers to expand the functionality of IIS 7 and Web site applications, and even to write programs that manage IIS 7 (for example, to program IIS 7 to build Web sites or virtual directories).

Summarize:

The way that different IIS versions enter the CLR is not the same as when the maximum change between IIS versions is:

    1. IIS5 to IIS6 improvements, mainly HTTP. sys.
    2. IIS6 to IIS7 improvements, mainly ISAPI improvements.

Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.

What happened before MVC series (1): Entering the CLR

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.