Differences in IIS Classic mode integration mode (reprint)

Source: Internet
Author: User
Tags metabase

The mapping of application Pool and Worker Process are maintained in IIS Metabase. The WAS (Web administrative Service), based on such a mapping, passes the request that exists in a application Pool Queue to the corresponding Worker Process (if not, creates such a Process). When the Worker Process is initialized, the ASP. Isapi,asp.net ISAPI loads the CLR. Finally, a application Domain is created for application through the Create method of the Appmanagerappdomainfactory, ProcessRequest processing through Isapiruntime Requ EST, which then enters the process into the ASP. NET Http Runtime Pipeline.

IIS6 the process of operation:

Iis

Analysis indicates:

Under User mode, HTTP. SYS receives the request, and then it looks at which application Pool is based on the application of the request according to Metabase in IIS, 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 (run under User mode).

The mapping of application Pool and Worker Process are maintained in IIS Metabase. The WAS (Web administrative Service), based on such a mapping, passes the request that exists in a application Pool Queue to the corresponding Worker Process (if not, creates such a Process). When the Worker Process is initialized, the ASP. Isapi,asp.net ISAPI loads the CLR. Finally, a application Domain is created for application through the Create method of the Appmanagerappdomainfactory, ProcessRequest processing through Isapiruntime Requ EST, which then enters the process into the ASP. NET Http Runtime Pipeline.

A few points of knowledge:

    • HTTP. SYS: (Kernel) is a component that listens for (Listen) HTTP requests from outside and forwards them to the appropriate application pool, based on the requested URL (application pool). When this HTTP request is processed, it is also responsible for sending the results of the processing. To provide better performance, HTTP. SYS internally establishes a buffer that stores the results of the most recent request processing.
    • Application Pool:iis always maintains a separate worker process: the application pool. All processing occurs in this process, including the execution of the ISAPI DLL. For IIS6, application pools are a significant improvement because they allow the execution of a specified process to be controlled with a smaller granularity. You can configure the application pool for each virtual directory or the entire Web site, which makes it easy to isolate each application into its own process so that it can be completely isolated from other programs running on the same machine. From the Web processing point of view, if a process dies, at least it will not affect other processes.
      When an application pool receives an HTTP request, the worker process worker Process:w3wp.exe running in this application pool processes this HTTP request.
    • Worker processes: When a worker process receives a request, the corresponding ISAPI extension is first found and loaded according to the suffix (for example:aspx mapping is Aspnet_isapi.dll), and the worker process finishes loading aspnet_ After Isapi.dll, the ASP is loaded by Aspnet_isapi.dll. NET application is the CLR (. NET runtime).
      Worker process runs in an unmanaged environment, and objects in. NET run on top of the Managed Environment (CLR), and the bridge between them is the ISAPI extension.
    • Was (Web Admin Service): This is a monitoring program that can access various information placed in the Inetinfo metabase (Metabase) on the one hand, and is also responsible for monitoring the application pool (application Pool), the worker process in the working state, if necessary it will close an old worker process and create a new one instead.

IIS7 the process of operation:

Iis

Analysis indicates:

1. http. sys intercepts this request when the client browser begins to request a resource for a Web server.

2. http. SYS contacted was to obtain configuration information.

3. Was requested configuration information from the Configuration Store Center (applicationhost.config).

4, the WWW service receives configuration information, configuration information refers to similar application pool configuration information, site configuration information and so on.

5. The WWW service uses configuration information to configure the HTTP. SYS processing policy.

6. Was created a process for the request (if it does not exist).

7. The worker process processes the request and responds to HTTP. sys.

8, the client receives the processing result information.

In addition to the overall way IIS works, IIS7 differs from IIS6 in that it provides two application pool pipeline modes:

Classic mode: A pattern that is compatible with IIS 6 or earlier, a typical problem is that when dealing with a dynamic Web site like ASP, it works through a so-called ISAPI program as a plug-in. For different dynamic applications (such as asp,php, etc.), different ISAPI (Internet Server application programe Interface, Internet Servers application interface) is required. , in IIS, open handler mappings, and you can see that the handler for the ASPX Type page is Aspnet_isapi.dll.

Iis

Demonstrates how the IIS7 Classic mode works with the IIS6 application pool pipeline mode, which specifies different ISAPI (DLLs) to handle for different requests:

Iis

Integrated mode:ASP is no longer limited to aspnet_ as IIS6 Isapi.dll, but is liberated, starting with the HTTP request received by IIS, that is, into the control range of ASP. ASP. NET can exist in one request in IIS in each processing phase. Allows us to integrate ASP. NET better with IIS, or even allow us to write features such as module in ASP. To change the behavior (extension) of IIS. The benefit of integration is that it no longer uses ISAPI to improve speed and stability. As for extensions, we can have more control over IIS, and other types of requests. (for example, we want static Web pages to have some special behavior, too).

Iis

As in IIS7 integration mode, open handler mappings, you can see that the ASPX Type page is no longer a DLL, but a type.

Iis

Summary and extension:

The Classic mode of IIS6 and IIS7 needs to be aspnet_isapi.dll for processing ASP , while IIS7 integration mode does not require aspnet_ Isapi.dll to be processed, and the corresponding handler interface can be found directly based on the file name extension. For example, the ASPX handler is the System.Web.UI.PageHandlerFactory type.

After describing how IIS works, take a look at the operating mechanism within ASP.

First look at the IIS Processing model:

Iis

This article describes how IIS works, from initiating an HTTP request to responding to a request, which is mainly about when a request arrives at. NET Runtime. NET runtime is a series of work that occurs.

Let's look at the following. NET runtime work sequence diagram:


1.HTTP after the request enters the Web server, the HTTP. SYS first determines whether the requested page exists and, if so, forwards the requested information to the. NET Runtime. In this section, it is practical to complete two steps to hold the request information in the Httpworkrequest class for other steps to be called while the request is forwarded to the. NET Runtime. The Httpworkrequest class is critical in future operations, and it first converts HTTP request information into class information.
2. When the request arrives at the. NET runtime, the next operation will be done in the managed environment, when the request is actually entered. NET, the operation of the request information is performed by the. NET is implemented by the underlying class library. First, the. NET runtime will do two actions for the request information, one is to prepare the hostingenvironment, and the other is to call the Applicationmanager class to dynamically allocate the AppDomain for the HTTP request. And give the right to deal with the AppDomain.
3.HTTP after the request enters the AppDomain, will be taken over by the object Isapiruntime, on the one hand through the method ProcessRequest () HttpWorkerRequest object, on the other hand by the method startprocessing () The HttpRuntime object is generated, and the processing is then given to httpruntime (the HttpWorkerRequest object will be used as a parameter in the HttpRuntime method).
After the 4.HTTPRuntime receives the HTTP request, the method ProcessRequest processes the request. The information in the Httpworkrequest class in the 1th step is manipulated, and the implementation is implemented by the ProcessRequest method. The internal code is as follows:

  1. [AspNetHostingPermission (SecurityAction.Demand, Level=aspnethostingpermissionlevel.medium)]
  2. public static void ProcessRequest (HttpWorkerRequest wr)
  3. {
  4. if (WR = = null)
  5. {
  6. throw new ArgumentNullException ("WR");
  7. }
  8. if (useintegratedpipeline)
  9. {
  10. throw New PlatformNotSupportedException (System.Web.SR.GetString ("Method_not_supported_by_iis_integrated_mode", New object[] {"Httpruntime.processrequest"});
  11. }
  12. Processrequestnodemand (WR);
  13. }
  14. internal static void Processrequestnodemand (HttpWorkerRequest wr)
  15. {
  16. Requestqueue queue = _theruntime._requestqueue;
  17. if (queue! = null)
  18. {
  19. WR = queue. Getrequesttoexecute (WR);
  20. }
  21. if (WR! = null)
  22. {
  23. Calculatewaittimeandupdateperfcounter (WR);
  24. Url Resetstarttime ();
  25. Processrequestnow (WR);
  26. }
  27. }
  28. internal static void Processrequestnow (HttpWorkerRequest wr)
  29. {
  30. _theruntime.processrequestinternal (WR);
  31. }

5. After a series of drivers are passed in the httpruntime, the application is assigned to the HTTP request in the ProcessRequestInternal method. In this step, you will also create a HttpContext object.

    1. context = new HttpContext (WR, false); Build HttpContext based on HttpWorkerRequest
    2. IHttpHandler applicationinstance = httpapplicationfactory.getapplicationinstance (context); Get HttpApplication
    3. Handler2. BeginProcessRequest (context, this._handlercompletioncallback, context); Processing requests by HttpApplication

6. After step 5, the HTTP request information is forwarded by the basic information to the individual objects in ASP. The next operation triggers the pipeline events for some columns, at which point the request is actually transferred to HttpModule and HttpHandler.
Let's take a look at the often-said pipeline event creation process:

  1. internal override void Buildsteps (WaitCallback stepcallback)
  2. {
  3. ArrayList steps = new ArrayList ();
  4. HttpApplication app = Base._application;
  5. BOOL flag = FALSE;
  6. Urlmappingssection urlmappings = Runtimeconfig.getconfig (). urlmappings;
  7. Flag = urlmappings.isenabled && (urlMappings.UrlMappings.Count > 0);
  8. Steps. ADD (new Httpapplication.validatepathexecutionstep (APP));
  9. if (flag)
  10. {
  11. Steps. ADD (new Httpapplication.urlmappingsexecutionstep (APP));
  12. }
  13. App. Createeventexecutionsteps (httpapplication.eventbeginrequest, steps);
  14. App. Createeventexecutionsteps (httpapplication.eventauthenticaterequest, steps);
  15. App. Createeventexecutionsteps (httpapplication.eventdefaultauthentication, steps);
  16. App. Createeventexecutionsteps (httpapplication.eventpostauthenticaterequest, steps);
  17. App. Createeventexecutionsteps (httpapplication.eventauthorizerequest, steps);
  18. App. Createeventexecutionsteps (httpapplication.eventpostauthorizerequest, steps);
  19. App. Createeventexecutionsteps (Httpapplication.eventresolverequestcache, steps);
  20. App. Createeventexecutionsteps (Httpapplication.eventpostresolverequestcache, steps);
  21. Steps. ADD (new Httpapplication.maphandlerexecutionstep (APP));
  22. App. Createeventexecutionsteps (Httpapplication.eventpostmaprequesthandler, steps);
  23. App. Createeventexecutionsteps (httpapplication.eventacquirerequeststate, steps);
  24. App. Createeventexecutionsteps (httpapplication.eventpostacquirerequeststate, steps);
  25. App. Createeventexecutionsteps (Httpapplication.eventprerequesthandlerexecute, steps);
  26. Steps.  ADD (new Httpapplication.callhandlerexecutionstep (APP)); Call HttpHandler
  27. App. Createeventexecutionsteps (Httpapplication.eventpostrequesthandlerexecute, steps);
  28. App. Createeventexecutionsteps (httpapplication.eventreleaserequeststate, steps);
  29. App. Createeventexecutionsteps (httpapplication.eventpostreleaserequeststate, steps);
  30. Steps. ADD (new Httpapplication.callfilterexecutionstep (APP));
  31. App. Createeventexecutionsteps (Httpapplication.eventupdaterequestcache, steps);
  32. App. Createeventexecutionsteps (Httpapplication.eventpostupdaterequestcache, steps);
  33. This._endrequeststepindex = steps. Count;
  34. App. Createeventexecutionsteps (httpapplication.eventendrequest, steps);
  35. Steps. ADD (New Httpapplication.noopexecutionstep ());
  36. This._execsteps = new Httpapplication.iexecutionstep[steps. Count];
  37. Steps. CopyTo (this._execsteps);
  38. This._resumestepswaitcallback = Stepcallback;
  39. }

The pipeline event request sequence diagram is as follows:

Original Connection http://www.51itstudy.com/3648.html

Differences in IIS Classic mode integration mode (reprint)

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.