. Net Operating Mechanism

Source: Internet
Author: User
It is a compilation programming framework. Running is the library code compiled on the server for the public language runtime. It can be used for early binding to implement compilation to improve efficiency.

ASP. net pages are driven by events. The init event is first executed. In the code, the system automatically adds an oninit overload function, in this way, the oninit function is executed during page init. In this function, the initializecomponent function is executed. There are many control event proxy functions in this function. Expand the "Web formdesigner generated code" Page and we can see these. After executing init, the page is the load event, and the corresponding code is page_load.
The code that causes the event returned by the page. Of course, if the page is running for the first time, this step will not be taken.
That is to say, the page_load function is executed every time the page is refreshed, which is why some code should be written in
If (! Page. ispostback)
{...}
. For example, if you set an initial value in page_load in a text box, where is it stored? If it is placed outside the if clause, the value assignment statement will be executed every time you refresh the page. Even if the value of the text box is modified on the page, the value will disappear after the result is returned, but if it is placed in the IF clause, then, the returned value is still the previous value in the text box.
 
After an HTTP request is sent and received by the IIS server, IIS first loads the corresponding DLL file for it based on the page type you requested, then, the request is sent to the module that can process the request. in net, this module is called httphandler. Why can aspx files be processed by the server? That is because the default httphandler on the server is used to process aspx files, before IIS sends this request to a module that can process this request, it also needs to go through some httpmodules, which are default modules of the system, in addition, different httpmoduls must be processed before the HTTP request is sent to httphandler. This is like if we want to fly an international flight to a foreign country, before you actually get on the plane, the airport construction fee should be purchased, the identity should be verified through registration procedures, the luggage should be packed and checked, and the security inspection should be conducted. Now, the temperature and other inspections should be carried out, and a series of strict procedures should be adopted. What are the advantages of doing so? One is for some necessary processes, the other is for security, the third is to improve efficiency, and the fourth is for us to be able to control more links, that is, our control capability is enhanced.

The figure above allows us to see more clearly how an HTTP request is processed by the server. At the same time, we can see that the request is in charge of all client inputs. The figure shows four possible routes for an HTTP request. When you access this page for the first time, the request first goes through the processing of httpmoduls and httphandler, and in the processing of httphandler, the server will forward you to the page you actually want to access, then, you can use ASP engine to find the class behind the page and instantiate it as a temporary object. In this process, a series of events are triggered, some of the events need to be processed by the method in the object. Then, the server will send the processed page to the response object and then send the page to the client by the response object. This is the first route. When you resubmit some information on this page and continue sending requests to the server, because the sessions between your servers have been established, the temporary object you are located has been created on the server, so you do not need to initialize the page. Therefore, the second route is based on httpmoduls and httphandler, and then directly interacts with the temporary object, then return. The third line is different from the second line. when processing a request, if ASP cache needs to be called, the temporary object will directly extract information from the ASP cache and return it. the fourth route is when you refresh the page, the server receives the request and finds that the request has been previously processed, the processing results are stored in the output cache managed by a default httpmodule. Then, we can extract information from the cache and return the results without re-processing them.

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.