[Add to favorites] a good article about ASP. NET operating principles

Source: Internet
Author: User

[Post] original post address http://www.cnblogs.com/Heroman/archive/2005/05/12/153975.aspx

First, I would like to thank Bodhi for its native tree.

This chapter is the foundation and spirit of the book. The subsequent example chapter aims to verify the content of this chapter and its practices.
Section 1 describes ASP. NET running mode, this section focuses on the entire ASP. the operating mode of the. NET application is actually not about components, but is very important, because the component writer must
It is clear how ASP. NET Applications start. How to handle requests, how to deal with SESSION and other details, but this section may be very obscure for general readers.
It may help you understand everything. an ASP. NET Applications start with 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. when
After finding the site, if the requested resource is a WEBFORM ending with ASPX, IIS will give control to an ISAPI extension.
AspNet_ISAIP.DLL. At this time, control is transferred from IIS to ISAPI extension of ASPNET. It must be noted that the ISAPI extension level is lower than that of IIS, but higher
The user site, which is independent of the ISAPI outside the site after receiving the Processing request, will start an ASP. NET workflow. Then the requester
The request information is forwarded to the ASP. NET Working Process (called ASPNET_WP.EXE). Next, the control is obtained by ASPNET_WP. ASPNET_WP first
If the ASP. NET application requested by the requester (site or virtual directory, popular) does not own the APPDOMAIN, ASPNET_WP will create
APPDOMAIN and load the Assembly required by the requested ASP. NET application
The above steps in the APPDOMAIN show a conclusion and rule: the control is passed among the request handlers in a sequential manner, and, the previous requestor must be responsible for transmitting the information required by the next requestor. it is also responsible for loading or initializing the last handler, which is similar to the relay race in our life. question
Some people may ask: why is it so complicated? How can I transfer a request directly to ASPNET_WP through IIS? Not impossible, but the scalability of this processing process changes.
Low. aspnet isapi is a bridge between IIS and ASPNET_WP. Although it seems that it is only responsible for forwarding requests and other work, it will greatly expand the scalability.
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 have said
Like a process, 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). Every APPDOMAIN is an execution container, and every execution of an application or
ASP. NET application, the. NET execution environment will create an APPDOMAIN, and then load some DLL required by the application into the. APPDOMAIN function is like a process, but never
It is a process. You can understand that APPDOMAIN is the execution environment of ASP. NET applications. AspNet_WP
Not only is it responsible for creating APPDOMAIN (if it already exists, it will directly use this DOMAIN), but it will also forward the request to the corresponding
ISAPIRuntime object in APPDOMAIN. (The Isapiruntime object is part of the APPDOMAIN ). Dedicated ISAPIRUNTIME
Resolves the necessary information of the request. It transfers information and requests to HttpRuntime. Here, it must be noted that IsapiRuntime is a class and 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 and are created in ASPNET_WP.
At the same time, the APPDOMAIN will also be used as the runtime environment to create these two objects. Because several objects are described one after another, when
I read this book for the first time, especially when I saw it, and I felt very dizzy because of the First. NET pair.
FRAMEWORK class libraries are not familiar with. Second, I am confused about the operating principles of ASP. NET for the first time. I always want to associate these object names with a DLL or a specific file.
It should be. In fact, whether ISAPIRuntime or HttpRuntime, they are implemented as part of the APPDOMAIN when the APPDOMAIN is created.
Examples. 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.
It is easy for beginners to refer to the cloud. In fact, from IIS to ISAPI is the first part of the request, that is, accepting customer requests. From ISAPI to APPDOMAIN, it is the second part.
Points, that is, the initialization part, aims to establish a big environment for request processing, prepare for the following request processing and running ASP. NET applications.
Next, after the APPDOMAIN Initialization is complete, we need to establish a session. Therefore, the request is accepted by HttpRuntime. The main task of HttpRunTime is
Create an HttpContext object for each customer who initiates the request. This object manages the HttpSession object. Each visitor has its own HttpContext
Objects and HttpSession objects, which can be stored in. NET
Find the corresponding class name in the 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 do not need to know the details. As long as you know who created and who was called, httpruntime is responsible for creating httpcontext and httpsession, and httpcontext is responsible for managing httpsession until httpruntime has created httpcontext. In fact, your application is still not running, or the requester's request is not actually processed. The previous work is both preparation or auxiliary work. in addition to the above object, httpruntime also creates httpapplication. the process of creating an application object is complicated. next, httpapplication calls the processrequest method to process user requests. This method calls the corresponding httphandler to process user requests, httphandler processes the request based on the extension of the file requested by the user, and sends the request result, that is, HTML, to the client browser.
In addition, the complexity of the process is far beyond 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 of
Method, but the general process is as described above. However, I did not strip the details of object creation for everyone. the content in Mr. Huang's original book is actually very detailed. but why?
Is it hard to get started? 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 first, and then describe the details.
Details and program are 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
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.
Easy 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 shows the entire ASP. the functions and processes of each object during the NET application running process are illustrated. of course, the illustration discards technical details, such as how to create an HttpApplication.
 
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.