Read notes-understand one of the underlying ASP. NET Architectures

Source: Internet
Author: User
Tags what is asp

What is ASP. NET?

====================

ASP. NET is a complex engine that uses hosted code to process Web requests from start to end.

The entire ASP. NET engine is fully built on managed code, and all the extension functions are provided through the extension of managed code.

 

What is ISAPI?

====================

ISAPI is an underlying, unmanaged, Win32 API. the spec of ISAPI is very simple and optimized for performance. they are very underlying-they process the list of original pointers and function pointers for processing callback functions, but they provide the underlying and performance-oriented interfaces through which, developers and tool providers can hook up their programs with IIS. because ISAPI is very underlying, it is not suitable for developing application-level code, and ISAPI is mainly used for bridging interfaces, that is, the upstream tool provides the application server type function.

For example, ASP and ASP. NET are both built on ISAPI, and cold fusion is also the same. Most Perl, PHP, and JSP running on IIS are also implemented.

 

ISAPI is an outstanding tool that can provide efficient APIs for upper-layer applications, so that upper-layer applications can abstract information provided by ISAPI. in ASP and ASP.. net. Abstract The information provided by the ISAPI into objects such as request and response, and use them to read the corresponding information in the ISAPI request. for ASP. net.. netRouting Mechanism. All the heavy load and processing, and even the processing of request threads are handled by the ASP. NET engine and your own code.

 

What is the relationship between ISAPI and ASP. NET?

====================

In fact, Asp. net interacts with IIS through the ISAPI extension on Microsoft's platform. This extension is hosted. net runtime and ASP. net runtime. ISAPI provides the core interface, Asp.. net uses the unmanaged ISAPI code to obtain requests from the Web server through this interface and send responses back to the client. the content provided by ISAPI can be obtained through common objects (such as httprequest and httpresponse). These objects expose unmanaged data through a well-defined and accessible interface.

 

What are ISAPI extension and ISAPI filter?

====================

ISAPI extension and ISAPI filter are two protocols supported by ISAPI.

ISAPI extension is a request processing interface that provides processing logic for Web Server Input and Output. Essentially, it is an interactive interface. asp and ASP. NET are implemented as extension.

ISAPI filter is a hook interface that provides some functions, including viewingEveryThe request arrives at IIS and then modifies the content or behavior of some functions. authentication is such a function.

By the way, ASP. NET uses two concepts to map ISAPI functions: HTTP handlers (extensions) and HTTP modules (filters)

 

How does a Web Request go from a browser to ASP. NET?

====================

1. the user sends a request from the browser. The method can be a. Enter the URL; B. Click the hyperlink C. Submit the HTML form D. Call the Web Service Based on ASP. NET

2. the IIS of the Web server obtains the request and displays the request file extension.

3. IIS sends ASP. NET registered extension requests to ASP. NET's isapi dll -- aspnet_isapi.dll according to the configuration in application extension (script map.

4. ASP. NET allocates requests again based on the obtained request extension. The allocated destination is the HTTP handler corresponding to the request.

 

What is HTTP handler?

====================

Each HTTP handler is A. Net class that processes the extension of a file. Its internal behavior can be simple and complex.

 

Can you sum up IIS and ASP. NET to find the correct information in the request?

====================

The extension. IIS finds ASP. NET Based on the extension, and ASP. NET finds HTTP handler Based on the extension.

 

Since both IIS and ASP. NET use extensions to route requests, how can I configure these extensions?

====================

You should manually set the extension name. Use the aspnet_regiis.exe tool to ensure that all mappings are correctly set.

CD <. netframeworkdirectory>

Aspnet_regiis-I

This command registers a specific version of ASP for the entire web site. net runtime, including script (Extension) ing and client script Library (including code for control Verification ). note that it registers <. specific versions of CLR (such as 1.1, 2.0) installed in netframeworkdirectory> ). the aspnet_regiis option allows you to configure different virtual directories. for each version. the. NET Framework has different versions of the aspnet_regiis tool. You need to run the corresponding version of aspnet_regiis to configure the specified version for the web site or virtual directory. net Framework. from ASP. net2.0 began to provide ASP.. Net configuration page, which can be used in the IIS console for interactive configuration.. Net version.

 

What is the application pool of IIS6?

====================

The application pool is a separate worker process created by IIS6. All the processes, including the execution of the ISAPI Dynamic Link Library, occur in this process.

 

What are the benefits of the application pool?

====================

The application pool is a major improvement of iis6. it has more detailed control over what can be put in a process. from the virtual directory to the entire site, you can set the application pool, so that you can isolate each web application into their own process, it has nothing to do with running Web applications on the same machine. A crash occurs, and other tasks still run.

The application pool is highly configurable.

It is easier to be monitored and managed.

Optimized Performance. Because the application pool Directly Interacts with the kernel-State HTTP. SYS driver, the performance of HTTP operations is higher.

Application pool for ASP. net has some internal understanding and support, Asp. net can use the underlying API of the application pool, which can remove the burden of caching from ASP. the net layer is directly transferred to the Web server cache.

ISAPI extension runs in the application pool ,. net runtime also runs in the same process, so ISAPI and. net runtime communication is in-process communication, of course, more efficient than the iis5 naming pipeline communication.

 

What is the first function entry to request access to ASP. NET?

====================

Isapiruntime. processrequest ()

 

How does a call go to isapiruntime. processrequest? What have you done after entering?

====================

W3wp.exe hosts. Net runtime.

ISAPI. dll calls a small number of unmanaged interfaces through low-level COM objects. These underlying com will eventually be called to an instance of the isapiruntime class.

ASP. net System. web. the hosting namespace has an interface called iisapiruntime. this is an interface exposed to the caller through COM. the COM interface is used to complete the extension from ISAPI to ASP. NET Component call function. that is to say, the iisapiruntime interface is a non-hosted code access point.

The signature of the processrequest method in the interface is as follows:

[Return: Financialas (unmanagedtype. I4)]

IntProcessrequest ([in] intptr ECB,

[IN, financialas (unmanagedtype. I4)]IntUseprocessmodel );

Note that the ECB parameter, short for ISAPI extension control block, is passed to the processrequest method as an unmanaged resource. the processrequest method uses ECB as the basic input and output object used by the request and reponse objects. ECB contains all the underlying information of the request sent by the browser, including server variables, input streams, and output streams to be written back to the client. the reference of a single ECB basically provides all the functions for accessing ISAPI requests. processrequest is the portal for ECB to deal with managed code and also an exit. that is, once the processrequest method ends, Asp. net Processing is over.

 

ISAPI extension is an asynchronous request. that is to say, the ISAPI extension(for example, asp.netmask will return to the worker route (w3wp.exe) or IIS thread of the called worker, but keep the ECB of the current request alive. ECB contains a mechanism for ISAPI to know that the request processing has ended (through ECB. serversupportfunction). This mechanism will release the ECB after receiving notification from the ECB. this asynchronous process can quickly release ISAPI worker threads and forward processing tasks to ASP. independent threads managed by. net.

 

ASP. net receives a reference from the ECB and uses it internally to obtain information about the current request, such as server variables, post data, and output information sent to the server. the ECB structure is alive before the end of request processing. in timeout, the ECB will be destroyed. as long as the ECB is still there, the processing is not over yet, Asp. net will always deal with it, and the output results will be written to the ISAPI output stream (ECB. writeclient. when the request ends, ISAPI extension is notified, and then it will know that ECB can be released. this process is very efficient because. net classes basically act around the high-performance, unmanaged isapi ecb wrapper.

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.