Asp. NET underlying architecture from browser to asp.net

Source: Internet
Author: User
Asp.net| Architecture | Browsers let us start with a typical asp.net Web request's lifecycle. When the user enters a URL, clicks on a hyperlink or submits an HTML form (form) (a POST request, which is generally a GET request relative to the previous two). Or a client program might call a asp.net-based webservice (also handled by ASP.net). On the Web server side, IIS5 or 6, get this request. At the bottom, ASP. NET and IIS interact through the ISAPI extension. In a asp.net environment this request is usually routed to a page with an. aspx extension, but how the process works depends entirely on how the HTTP handler that handles a particular extension is implemented. In IIS. ASPX is mapped to the asp.net ISAPI extension dll-aspnet_isapi.dll through ' Application Extensions ' (also known as script mappings). Each request needs to trigger the asp.net (to process the request) through an extension that is registered to Aspnet_isapi.dll.

Depending on the extension asp.net routing the request to a suitable processor (handler), the processor is responsible for obtaining the request. For example, the webservice. The ASMX extension does not route the request to a page on disk, but rather to a class that is marked as WebService by a special attribute. Many other processors and ASP.net are installed, of course you can also customize the processor. All of these HttpHandler are configured in IIS to point to the asp.net ISAPI extension and on the web. Config (translated: ASP. NET in the handler is in machine. Config, which can, of course, overwrite the configuration in Web.config) is configured to route the request to the specified HTTP handler. Each handler is a processing special extension. NET class, from a simple Hello world that contains just a few lines of code, to a very complex handler such as a ASP.net page or a webservice handler. Currently, it is OK to understand that the mapping mechanism for ASP.net is to use the extension to receive requests from the ISAPI and route them to the handler that handles the request.

ISAPI is the first and most efficient portal for customizing Web request processing in IIS.

ISAPI connections

ISAPI is the underlying unmanaged Win32 API. The interfaces defined by ISAPI are very simple and are optimized for performance. They are very low-level-handle pointers and function pointer tables for callbacks-but they provide the lowest and most efficient interfaces that developers and tool providers can use to hook up to IIS. Because ISAPI is very low-level, it is not appropriate to develop application-level code, and ISAPI tends to be used primarily for bridging interfaces, providing the ability to apply server types to upper-layer tools. For example, both ASP and ASP.net are built on ISAPI, Cold Fusion, most perl,php and JSP implementations that run on IIS, and many Third-party solutions, such as my Wisual FoxPro Web Connection framework. ISAPI is an outstanding tool that provides an efficient pipeline interface for upper-level applications, so that the upper application can abstract the information provided by the ISAPI. In ASP and ASP.net, the information provided by the ISAPI interface is abstracted into objects such as type request and response, which are used to read the corresponding information in the ISAPI request. Imagine the ISAPI as a conduit. For ASP.net, the ISAPI dll is very "thin", only as a routing mechanism to forward the original request to the ASP.net runtime. All of those heavy burdens and handling, even the request thread management, occur inside the ASP.net engine and in your code.

As the most protocol, the ISAPI supports both the ISAPI extension and the ISAPI filter (filter). An extension is a request-processing interface that provides the logic to handle the input and output of a Web server-essentially a process (thing?) Interface. Both ASP and ASP.net are implemented as ISAPI extensions. ISAPI filters are hook interfaces that provide the ability to view every request to enter IIS, modify the content of the request, or change the behavior of a functional type, such as authentication. By the way, ASP. NET uses two concepts to map functionality similar to ISAPI: HTTP handler similar extensions, and HTTP module-like filters. We'll discuss them in detail later.

An ISAPI is the initial entry point for starting a asp.net request. Asp. NET maps several extensions to its ISAPI extension, which is located in the. NET Framework in the directory:

<.net Frameworkdir>\aspnet_isapi.dll

You can see these mappings in the IIS service management interface, as shown in Figure 1. View the Home Directory Configuration page in the properties of the site's root directory, and then view the configuration | map.

  

Figure 1:iis Maps to a variety of extension names such as. aspx to asp.net ISAPI extension. Through this mechanism the request will be routed to the ASP.net processing pipeline at the Web server level.

Because. NET needs to be part of them and you should not set these extensions manually. Use the Aspnet_regiis.exe tool to ensure that all mappings are set correctly:

cd;. Netframeworkdirectory>

Aspnet_regiis–i

This command registers a specific version of the ASP.net runtime for the entire Web site, including script (extension) Mappings and client script libraries (including code for validation of controls, and so on). Note that it registers a specific version of the CLR (such as 1.1,2.0) that is installed in <.net frameworkdirectory>. The ASPNET_REGIIS option allows you to configure different virtual directories. Each version of the. NET Framework has its own 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. The ASP.net configuration page, which you can interact with in the IIS Management Console, is available from asp.net2.0. NET version.

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.