Asp. NET execution model of the IIS server processing process

Source: Internet
Author: User

I've seen a lot of this before on the Internet, but I think it's too "esoteric" to see it, and it's not easy to understand it, so I want to explain it in a simpler way, so it's easy to understand.

This time we focus on the process of Web server processing during user request to page rendering. Let's start with a page request from the ASP. See below for a simple execution model of a request

(Note that this is the first request to the ASP. Index.aspx page, so you need to compile dynamically):

We have simply described a Web request process through the ASP. NET implementation model, note that in different versions of IIS, the processing model and the communication method are not the same, and above IIS7.0, ASP. NET has been integrated into IIS as a module.


We continue to elaborate on the above process:

    1. First we send a page request through the browser to the IIS server, because it is the first request Index.aspx,iis will send the request to ASP after the compile period (load Aspnet_isapi.dll)
    2. Since ASP. NET is run through the CLR, and the CLR knows only MSIL (Microsoft intermediate Language), ASP. NET will determine whether the code has been compiled, if not compiled, will walk two times the compilation process, or skip the compilation into the execution period,
    3. Perform a series of module processing during the execution period, and then return the request


Then let's look at what is a two-time compilation?

Two-time compilation:

The process of compiling source code files through the compiler into intermediate language code and metadata, and then compiling them into native machine language code.

Don't feel good to understand? Then look directly at the picture!

As above, we call this two compilation process a two-time compilation.

Two compilations are executed when the site page is first requested, ASP. NET judgment has been compiled will no longer go through the compilation process.


After reading two compilations, we then make the first request to the ASP. Index.aspx:
User Request->iis Server->asp.net-> Two compilation->msil (code compiler)-native language (JIT)-Execution period

    1. Create an application domain
    2. Initializing Core objects
    3. Start the application
    4. Processing requests based on configuration, a series of HttpModule and HttpHandler

The final request passes through a layer of layers HttpModule and HttpHandler after the initialization of the page, loading, rendering, user operation, unloading.


This explains why our site page is always slow for the first time, because the first request took the process of compiling, loading a series of initialized things.


If I have multiple application pools deployed on one IIS server, I send a request how does IIS know which one I'm requesting? This will refer to an HTTP. sys component.

In fact, the HTTP. SYS response is first triggered by IIS before the request is delivered to ASP. http. SYS is responsible for passing the request to the appropriate application pool. And then go on the ASP. NET process above
Whenever an application pool is created, the ID of the pool is generated and registered in the HTTP. sys file.


Summarize:

such as: During the execution of a series of operations, and then through the HttpModule module to reach the HttpHandler processing program, and finally began to enter the page life cycle related things.

If you are helpful, you can also follow the public number Codel for more information.

Asp. NET execution model of the IIS server processing process

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.