Several terms in. net

Source: Internet
Author: User
Tags reflector
A: XX Factory: The Factory mode is used to generate an object. The object responsible for generating (producing) an object task is called A Factory. The factory mode is a construction mode. You should be able to understand it through attachment 2.

B: CLR Host: do not be intimidated by this term. Actually, there is nothing. CLR Host is actually loading CLR in an unmanaged application. An unmanaged application (such as SQL server2005) needs to run managed code (such as a stored procedure written in C #), so it needs to be loaded in its process. NET runtime CLR, that is, the CLR must be hosted in the process that runs SQL server.

In fact, the word "boarding" in your life can also help you understand. If you live with your family, we will not say that you host your house. If you come to a distant relative and live in your house one day, he will host your house. If you use the Dependency tool for a managed program, you will find that its running depends on MsCoree. dll, but for an unmanaged program, you should not see this Dependency (Dependency can only see the static Dependency ), because the host CLR is usually Dynamically Loaded through LoadLibrary (I am not sure about this, because I have a few examples of .exeand .dll, such as w3wp.exe, inetinfo.exe, etc ).

For more information about boarding, see section 1.3 loading. NET runtime and section 20.2 CLR boarding in. net Framework programming (revised).

C: application domain (AppDomain): logically speaking, an application domain is similar to a process. It is a logical container. The concept of "Domain" is actually the concept of a range. It seems that it was my region after I circled it. In terms of implementation, AppDomain is also a class in the System namespace. You can see the information of this class through Reflector. You can also refer to 20.3 application domains in. NET Framework programming (revision).

D: Container: the Container is the object that contains other objects.

E: Pipeline: the pipeline is two processes that communicate through the pipeline. For example, in IIS 5, inetinfo.exe sends the request to aspnet_wp.exe (named pipeline) through the "name Pipeline" because a random name is given to the pipeline ). Now another http pipeline (http pipeline.exe, which is in the same process (for example, iis6.0w3wp.exe) has been created. What is the problem? Let's take a look at the essence of the "Pipeline". Let's analyze the pipeline in real life. We can see that the pipeline has the following two features:

A. From what flows in it, we can see that something enters from one pipe and comes out from the other. Things are still the original things.

Pipe B can be seen from the external form: it connects two different places, that is, it represents a flow direction, a process, and a sequence.

Yes, the terms in our computer are the same as those in our daily life. The HTTP pipeline mentioned here refers to the Http Module and Http Handler objects. What flows through these HTTP pipelines is the same object, that is, the Http Context object. In the Http Module and Http Handler objects, Http Context objects are processed, but content in the Http Context object is modified (the biggest change is to assign content to the Response object ), however, his structure was not changed.

2. Several misunderstandings:

A: The Http Application and the Application object we use on the page: the two are different. The former represents our entire Application. For every request, HttpApplicationFactory assigns an Http Application object, which manages the request processing logic, or it's the event scheduling center. You can see our Global. asax actually inherits HttpApplication. The Application we use on the page is a state concept. It is an instance of HttpApplicationState and a subobject "embedded" on the httpContext object.

B:. NET runtime and HTTP runtime: NET Runtime is CLR, and its core is MsCorEE. dll. The latter is an HTTP RunTime instance of the httpRuntime class in System. web. HttpRuntime is responsible for the creation and initialization of Http Application and Http Context. The two are different.

C: Http Application, Http Context, Http Module, Http Handler

Each request is routed to an HttpApplication object. The HttpApplicationFactory class creates an HttpApplication Object pool for your ASP. NET application based on the application load and distributes references to the HttpApplication object for each request.
I once again stressed that the main responsibility of HttpApplication is to act as the event controller of the Http pipeline, httpApplication itself knows nothing about the data sent to the application-it is just a message object that communicates through events. it triggers the event and transmits a message to the called function through the HttpContext object. the status data of the current request is maintained by the HttpContext object. You can use Reflector to take a look at the HttpContext class, which contains objects indicating the status, such as Request, Response, Application, Server, and Session. In fact, HttpContext itself also represents a State. It has two more important attributes: Current and Items. The former is used to represent itself, and the latter is a set that can store all objects, you should not underestimate the latter. It is really useful. In view of my past love history with Context, I will write a blog to introduce him in detail later.

HttpModule. Some people say that it is a "Monitor" and some say it is a "filter". They all look at httpModule from different perspectives, so they are all right. HttpModule provides pre-processing for requests before they enter the http Handler processing and post-processing for http handler processing. Now that pre-processing can be performed, it can certainly intercept requests and will not be handed over to http handler for processing, implement the "filter" function. From another perspective, once a request arrives, the httpModule (the InitModules () method for initializing the httpModule in httpApplication) will be initialized ), of course, this means that the httpModule monitors the request (that is, the source of the "Monitor"). After all, it is the beginning for us to process the request. Note that ASP. NET only provides us with this capability. You need to add Event code to implement control. For example, you can. add code to the event handler function in asax. You can also define the http module by yourself. in appendix 4 asp-net frameworkdepth samples, you can see the specific instance. As for http Handler, our page is actually an http Handler. web. UI. the IHttpHandler interface is implemented in the declaration of the Page class (the base class of all pages. You can read the 8.5 image control in the. NET Programming Technology story to see the benefits of http Handler.

However, I do not agree as stated in Appendix 4 asp-net framework .pdf, the request is considered to be a single-line stream through Http ApplicationFactory-> Http Application-> Http Module-> Http Handler-> .... As you can see in Figure 6 of the appendix 1《. All the processing starting points are in the leftmost ASP. NET. Why? In reality, both Http Module and Http Handler are "embedded" in Http
On the Application, the entire process is scheduled by the http Application. From another perspective, most of the http Application functions are implemented by the Http Module. These Http modules are actually instantiated classes when the http Application starts and parameters and Processes requests, you can. config ttp Module> View the predefined http Module, including session and verification.

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.