. NET Senior Architect 11 cut starts at the source

Source: Internet
Author: User

Asp. NET request processing mechanism

Asp. NET request processing mechanism is divided into classic form and integrated form   Classic Form Classic form is for compatibility with previous version, Using the ISAPI extension to invoke the ASP. NET Runtime Library, a Web application that was previously running under IIS6.0 is migrated to the IIS7.0 simply by configuring the application as a classic, and the code is functioning without modification at all. The integrated form of   integration is a unified begging pipeline that combines the ASP. NET pleading pipeline with the IIS Central pipeline, which provides better performance, enables the modularity of configuration and management, and increases the agility of using managed code modules to extend IIS. Assuming that the old Web application works in the integrated form of IIS7.0, it may require that the application's Web. config file be stopped, especially when the custom module that completes the IHttpHandler interface is used. IIS7.0 can support two forms of application simultaneously on the same service device.     One, a request is received, the client sends a server-side   second HTTP request corresponding to an HTTP message. )   HTTP. sys component gets the HTTPS request, which is forwarded to IIS for processing, the process, first through the cache to see if there is a cache, if there is cache directly from the buffer cache read to IIS, did not respond to the request after the IIS.   Iv. When the server IIS receives the request, it determines whether the requested content is static resource or not, and it is still resource, it is read directly; if the dynamic resource, processing dynamic resources, to the query mapping table to find out which extender to handle this request, generally by aspnet_ Isapi.dll This component to be processed and read after the response request is generated.   Dynamic resource W3WP.exe will load  aspnet_isapi.dll     when the client requests a *.aspx paging file to the Web server, it is similar to ASP. This HTTP request is also intercepted by the Inetinfo.exe process (WWW service), which, after judging the file suffix, transfers the request to ASPNET_ISAPI. DLL and ASPNET_ISAPI. DLL will send this HTTP request to aspnet_wp via an HTTP pipeline pipeline. EXE process, when this HTTP request enters aspnet_wp. EXE process, the ASP. NET Framework will process the HTTP request through httpruntime and return the result to the client after processing is complete.   Load  .net for the VI, NET runtime runtime    If the Web application is loaded for the first time, the. NET runtime is first loaded by Aspnet_isapi.dll (primarily, the. NET Framework on the calling server creates the CLR runtime). An IIS worker process has an application pool that can host more than one application domain appdomain.   Application Pools     application pools can be seen as containers that load computers to allocate memory to dynamic Web sites   VIII. application domains     use. NET is an executable program that is not directly hosted in the process, but is hosted in the application domain (AppDomain). The application domain is. NET introduces a new concept, which is less than the resources consumed by the process and can be seen as a lightweight process. The   IX, Isapiruntme.processrequest () method is the first entry to the ASP. NET, the core processing part is just beginning. This is what I call the prelude, because it is in the core processing part of the ASP, the HTTP request is passed to the Isapiruntime object step-by-step, after we continue to explore the request processing mechanism of ASP, this is the end today!  

Integrated form

Official Microsoft Pictures
From this life cycle, it can be seen that the integrated mode, regardless of managed or native code, can be intercepted by managed code that is inserted into the kernel code in the authentication and execution handlers. Under IIS6, to intercept native code, such as an HTM file, you need to write WIN32 unmanaged code, but it also preserves the extended ISAPI, and we can write managed code to intercept requests for managed files. Although IIS6 can also insert an ISAPI-aspnet_isapi.dll extension through IIS, it handles blocking of the HTM file, but it actually walks two channels, first for native code interception within IIS, and then for managed-code ISAPI interception. The Classic mode is to preserve and IIS6 the same processing method, the previously developed code, can be easily ported to IIS7.

The IIS7 integration mode also adds Maprequesthandler, Logrequest, and Postlogrequest events, which are thrown if these processing events are added in Classic mode: This operation requires the use of IIS integrated pipeline mode. If you do not allow IIS to handle the configuration and processing of incompatible integration modes in Integrated mode, you can configure it in Web. config:

<system.webServer>

<validation validateintegratedmodeconfiguration= "false"/>

</system.webServer> can.

In fact, the IIS7 integration mode is to allow users to write managed code handler, etc., to insert managed code into the IIS kernel code to parse, so that you can precisely control any request, resulting in better extensibility. But the disadvantage, I think that the integration mode, any file requests can be managed code processing, others do not want to test the class picture and static files with managed code, you have to think of other ways, this will not reduce internal efficiency, but this is a personal point of view.

If you enable HttpModule to intercept static file requests in IIS7 Integrated mode, you need to set runallmanagedmodulesforallrequests= "true" under the Web.server section

. NET Senior Architect 11 cut starts at the source

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.