[Reading Notes] [in-depth analysis of ASP. NET Component Design] Chapter 3 about ASP. NET operating principles
Source: Internet
Author: User
This chapter is the foundation and spirit of the book. The subsequent example chapter is to verify the story and practice of this Chapter. The first section is about ASP. net running mode, this section focuses on the entire ASP. NET Application ProgramIn fact, it is not about components, but it is very important, because the person who writes components must know ASP clearly. NET application startup. how to handle requests, how to deal with session and other details, but this section may be obscure to general readers. the following explanation 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. 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 level of ISAPI extension is lower than that of IIS, but higher than that of the user site. It is independent of the level of ISAPI that starts an ASP. net Cheng. 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 and so on) load to appdomain the above steps can see a conclusion and law: the control is in the form of a flow between each request handler, 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. 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 this, appdomain 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 Ppdomain, which is the second part, that is, the initialization part, aims to establish a large environment for processing requests, for the following processing requests and running ASP. 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, such as 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 HT Tphandler is used to process user requests. httphandler processes requests based on the file extension of the user request, and sends the request result, that is, HTML, to the client browser, 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 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 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.
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