Process of IIS Server Based on ASP. NET execution model, asp. netiis

Source: Internet
Author: User

Process of IIS Server Based on ASP. NET execution model, asp. netiis

I have read a lot about this on the Internet before, but I personally think it is too "esoteric" and not easy to understand. So I want to describe it in a simpler way to facilitate understanding.

 

This time, we will focus on analyzing the presentation process of user requests to the page.Web server processing process. Let's start with a page request from an ASP. NET site. Let's first look at the simple execution model for a request.

(Note that this is the first request to the Index. aspx page of The asp.net site, so dynamic compilation is required ):

 

We use ASP. the execution model of NET briefly describes a web request process. Note that the processing model and communication mode are different in different IIS versions, asp.net above IIS7.0 has been integrated into IIS as a module.


We will continue to elaborate on the above process:

  1. First, we send a page request to the IIS server through the browser. Because this is the first request for index. aspx, IIS will forward the request to ASP. NET and enter the compilation period (loading aspnet_isapi.dll)
  2. Because ASP. NET is run through CLR, while CLR only knows MSIL (Microsoft intermediate language), so ASP.. NET checks whether the code has been compiled. If the Code has not been compiled, the second compilation process will be followed. Otherwise, the compilation will be skipped and the execution will start,
  3. Process a series of modules during the execution period, and then return the request


Next let's take a look at what is secondary compilation?

Secondary Compilation:

Compile the source code file into the intermediate language code and metadata through the compiler, and then compile it into the local machine language code during execution.

Does it feel hard to understand? Let's look at the picture!

As shown above, the two compilation processes are called secondary compilation.

The second compilation is executed when the site page is requested for the first time. ASP. NET judges that the compiled content will not go through the compilation process.


After secondary compilation, we will make the first request to Index. aspx of the asp.net site:
User request-> IIS server-> ASP. NET-> secondary compilation-> MSIL (code compiler)-> local language (JIT)-> execution period

  1. Create an application domain
  2. Initialize core objects
  3. Start the application
  4. Process requests according to configuration, a series of HTTPModule and HTTPHandler

Finally, the request enters the page initialization, loading, rendering, user operations, and uninstallation through the HTTP module and HttpHandler layers.


This explains why our website page is always slow when it is requested for the first time, because the compilation process is used for the first request and a series of initialization items are loaded.


If I haveMultiple application pools and multiple sitesAll are deployed on an IIS server. How do I know which one I request when I send a request to IIS? An HTTP. SYS component is mentioned here.

In fact, before IIS sends a request to ASP. NET, the HTTP. SYS response is triggered first, and HTTP. SYS is responsible for passing the request to the corresponding application pool. Then proceed to the ASP. NET Process
Each time an application pool is created, the ID of the pool is generated and registered in the HTTP. SYS file.

 


Summary:

For example, a series of operations will be performed during the execution period, and then the HttpHandler processing program will be reached through the HttpModule module, and the related items of the page will be started.

If it helps you, you can also follow the public account CodeL to get more information.

 

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.