) About the Asp.net running process

Source: Internet
Author: User
Many people have a thorough understanding of what Asp.net is like, especially how the httpmodule runs. I hope you can help me with it.
An ASP. NET application Program Is from IIS.
When you request a request containing ASP. when IIS receives the request (IIS is a Web service waiting process), after IIS receives the request, the site is located based on the host header, IP address, or port number requested by the requester.

After the site is found, if the requested resource is a webform ending with aspx, IIS will give control to an ISAPI extension ., the name is aspnet_isaip.dll. at this time, the control is transferred from IIS to the ISAPI extension of ASPnet ., it must be noted that the ISAPI extension level is lower than IIS, but higher than the user site, it is independent from the site

After receiving the Processing request, ISAPI starts an ASP. net workflow. then, the requester's request information is forwarded to ASP. net workflow (named aspnet_wp.exe ). next, the control is controlled by aspnet_wp. aspnet_wp first solves the information of the requester, if the requester requests ASP. NET application (site or virtual directory, popular) does not have appdomain, aspnet_wp will create an appdomain, and will be requested ASP.. NET application assembly (that is, those DLL, such as system. web. (DLL) is loaded into the appdomain.

In the preceding steps, we can see a conclusion and rule: the control is transmitted among various request handlers in a sequential manner, and the former request handler must be responsible for transmitting the information required by the latter. it is also responsible for loading or initializing the last handler, which is similar to the relay race in our life.

The problem is that many people may ask: why is it so complicated? How can I transfer a request directly to aspnet_wp through IIS? It is not impossible, but because of this, the scalability of this processing process is reduced. ASPnet ISAPI is a bridge between IIS and aspnet_wp. although it seems that it is only responsible for forwarding requests and other work. in this way, the scalability is greatly extended.

Another question is about appdomain, including me. I had a misunderstanding of appdomain at the beginning, and Microsoft talked about appdomain in a vague manner. Some people say it is the same as the process, however, I first understood it as an application pool in IIS, so I took a lot of detours. In fact, appdomain is neither a process nor an application pool in IIS .. all applications under. net run in the appdomain (I understand it myself). Each appdomain is a container for execution, and each application or ASP.. NET application ,. net execution environment will create an appdomain, and then load some DLL required by the application. appdomain functions are similar to processes, but they are never processes. you can understand that appdomain is ASP.. NET application execution environment.

Aspnet_wp is not only responsible for creating appdomain (if it already exists, use this domain directly), but also, after the appdomain is created, the request is also forwarded to the isapiruntime object in the corresponding appdomain. (The isapiruntime object is part of the appdomain ). Isapiruntime is responsible for solving the necessary information of the request. It transfers information and requests to httpruntime. Here, it should be noted that isapiruntime is a class, its full name is system. Web. Hosting. isapiruntime, and httpruntime is also a class, its full name is system. Web. httpruntime. Therefore, we can say that these two objects are part of the appdomain runtime environment. When aspnet_wp is used to establish appdomain, it will also be used as the runtime environment to create these two objects.

Since several objects are described one after another, when I read this book for the first time, especially when I saw it, I felt very dizzy because of the first pair. net Framework class library is not familiar with, second, Asp. net operating principle first contact. I can't figure it out. I always want to match these object names with a DLL or a real file. in fact, whether isapiruntime or httpruntime, they are instantiated as part of the appdomain when the appdomain is created. so they represent an instance of a class in the memory, that is, an object. in addition, some of the above operating principles seem to follow ASP. NET application is not directly linked. it seems that the question is not correct, and it is easy for beginners to refer to the cloud. in fact, from IIS to ISAPI is the first request, that is, accepting the customer request. from ISAPI to appdomain, it is the second part, that is, the initialization part. It aims to establish a big environment for processing requests, and process and run ASP for the following. NET application.

Next, after the appdomain Initialization is complete, you need to establish a session. Therefore, the request is accepted by httpruntime. The main task of httpruntime is to create an httpcontext object for each customer who initiates the request. this stuff manages the httpsession object. each visitor has their own httpcontext object and httpsession object. net Framework library, such as system. web. httpcontext, system. web. httpsessionstate.

It can be seen that the request processing process is very similar. process of event model processing in. net. several processing modules are concatenated to an event. in ASP. in the net operating principle, also, several modules process one request in turn, just like pipeline operations.

As a component developer, you must specify the hierarchy and call creation relationships of httpruntime, httpcontext, and httpsession objects. you don't need to know the details. You only need to know who created and who called it.

Httpruntime is responsible for creating httpcontext and httpsession, and httpcontext is responsible for managing httpsession

Until the httpcontext is created in httpruntime, your application is still not running, or the requester's request is not actually processed, the previous work involves preparation or auxiliary work.

In addition to creating the above object, httpruntime also needs to create httpapplication. As for the process of creating the application object, it is complicated. You can refer to it as a branch Process

Next, httpapplication calls the processrequest method to process user requests. This method calls the corresponding httphandler to process user requests. httphandler processes requests based on the file extension of the user request and returns the request results, that is, HTML is sent to the client browser.

In addition, the complexity of the process far exceeds the above description. Basically, Mr. Huang described ASP in Chapter 3, Section 1, using a dozen pages of text. net running process and principle, as well as some methods used to process requests, but the general process is as described above,, I did not strip the details of object creation to show to you. the content in Mr. Huang's original book is actually very detailed. but why do everyone seem to be struggling? On the one hand, this is because the principle has always been quite troublesome. On the other hand, it is because Mr. Huang did not describe the process and program to everyone before describing the details, then, the details and program are directly integrated. in this way, if the subtitles and content in this section are not linked together and the program is first summarized. after reading it, you will feel dizzy. in fact, the whole story is about ASP.. Net process the request. if you hide all technical details and only talk about the process, you may soon understand it. then I will show the technical details of each part of the process. I think it is much easier to understand. this is like telling a story. It is better to outline the story first.

Of course, I am not saying that Mr. Huang is not writing well. In fact, this section is very well written and can be easily understood. the process is very important. It is important that you know when something happens, and you can do some processing at the specified time point. in this regard, I will introduce ASP in later chapters of Mr. Huang. NET page object execution process is more important.

The following figure illustrates the functions and processes of each object in the ASP. NET application running process. Of course, the illustration discards technical details, such as how to establish an HTTP application.
 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1528241

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.