IIS 7 Managed Piping Mode Classic mode (CLASSIC) integration mode (integrated) analysis and understanding
IIS 7.0 supports two pipe modes: One is the latest integrated piping mode provided by IIS 7.0, and the other is the classic piping mode, which is provided by previous versions of IIS.
We can set the pipe mode through the application pool, which is especially useful for IIS administrators because it allows one server to run only one mode or two modes to run simultaneously on a single server.
There are significant differences between the Web.config files used by the two piping modes, and many Web.config files that work properly in classic piping mode do not work in integrated piping mode. with AppCmd.exe, we can automatically convert the configuration file format in classic piping mode to the configuration file format in integrated piping mode.
It is necessary to look at the structure of the various patterns first, and to study the differences between the two patterns.
1. Classic mode
In the Classic mode of IIS 6.0, ASP. NET is an ISAPI that is added to IIS. IIS 7.0 supports this mode for backward compatibility. However, Classic mode lacks a number of integrated modes to provide the features. In Classic mode, IIS has its own pipelines, which can be augmented by creating an ISAPI extension, which is notoriously difficult to develop. ASP. NET runs as an ISAPI extension and is only an integral part of the IIS pipeline.
The figure below is a good explanation for the above scenario. Note that in this case, the ASP. NET seems to be an afterthought-like outcome that only works when IIS handles ISAPI extensions.
Using the file name extension, you can determine which ISAPI handler to use. For example, you can map files with the extension. aspx and. ascx to Aspnet_ Isapi.dll, and maps files with an. asp extension to Asp.dll so that you can handle traditional ASP pages, and map files with the. php extension to Php.dll so that you can process the PHP page if you have already installed Php.dll.
In addition, some features are duplicated in the Classic mode of IIS 6.0 and IIS 7.0. For example, error handling is a repetitive feature, because IIS can handle asp.net pages, and asp.net can handle all pages that map handlers to aspnet_isapi.dll.
In IIS 6.0, we can map all file types to asp.net, but there are some limitations to doing so. The biggest limitation is how to handle the default document: A default document can be processed only if it is specified as the default document in Global.asax or in an HTTP module. Some custom configurations require the use of Aspnet_isapi.dll to process all file types. IIS 7.0 can easily resolve this problem.
Classic mode can run an existing Web site without having to modify web.config, so if you use a Web farm that includes both IIS 6.0 servers and IIS 7.0 servers, Or for some reason the Web.config file cannot be converted to a Web.config file that follows the new syntax, you can use Classic mode.
2. Integrated mode
with Integrated mode, asp.net can be used as an integral part of IIS. The functions of the IIS server are now divided into more than 40 modules, so the functions of IIS and asp.net are divided into different components. Modules such as StaticFileModule, Basicauthenticationmodule, FormsAuthentication, session, profile, and rolemanager are all part of the IIS pipeline. Note that formsauthentication, session, profile, and rolemanager are originally part of the ASP.net, and are not related to IIS.
The following illustration uses a module to explain the IIS pipeline. These modules, which were originally part of the ASP.net, are now an integral part of the IIS pipeline.
The IIS pipeline provides more than 20 events that developers can use to extend the functionality of the Web server. In fact, by creating custom modules and updating ApplicationHost.config, you can use only custom modules, without having to use the built-in modules provided by Microsoft, we can replace the modules in IIS 7.0 with custom modules.
3. Differences in configuration between two modes
IIS 7.0 makes changes to the configuration file that Web developers can use. For example,,<system.webserver> section is such a modification, both Classic mode and integrated mode can identify <system.webServer>, while,<system.webserver> Sections can be set in either the ApplicationHost.config file or in the Web.config file. The <system.webServer> section can control both static and dynamic pages. Even if the,<system.webserver> section is important in Classic mode, it can help web developers set up different IIS configurations in the Web.config file.
In Integrated mode, HTTP modules and HTTP handlers are no longer defined in <system.web>, but are defined in <system.webServer>. If you run an Web.config file that includes an HTTP module or an HTTP handler in Integrated mode, the failure will occur. Fortunately, Microsoft has already specified a 500.22 error message that explains how to migrate Web.config files step-by-step.
Configuration <system.webServer> node in IIS 7.5
Problem
The 404 page configuration <customError><error> node in IIS7.5 does not work
Analysis
<system.web> node is the main configuration node of previous versions of iis7.0, and after II7.0, IIS pipeline processing and ASP.net pipeline processing are integrated to improve the processing performance of asp.net. Because the program runs in the IIS7.5 integration mode, it needs to be configured in the <system.webServer> node, and the newly added <system.webServer> What modifications are required in the node to be fully effective in the IIS7 integration mode, including the following:
(1) <modules>-----equivalent to <system.web>
(2)
(3) <customError> <error>-----equivalent to <system.web>
Of the above three points, if you have custom httpmodules or httphandlers in your program, then 1th and 2nd are very important, please MSDN for details.
Configuration
<remove statuscode= "404"/>
<error statuscode= "404" path= "/404.htm" responsemode= "Executeurl"/>
Add
Errormode has three values, named Custom, Detailedlocalonly, Detailed, which means that the user and server always display a custom page, only server-side display of detailed error information, always display detailed error information to the user and server side.
Responsemode has file, Executeurl, redirect three layers, respectively, using server-side static files, executable URLs, URL steering.
Note that:
<customErrors>
Similarly, if Application_Error and <customerErrors> exist at the same time, there is a problem with the order of execution. Because of the priority Application_Error event > <customErrors> configuration Item, the code in the Application_Error event is executed preferentially when an application-level error occurs, if Application_ The Server.ClearError () function is invoked in the error event,<customererrors> the defaultredirect in the configuration section does not work because exception has been cleared; if application The Server.ClearError () function is not invoked in the _error event, and the error page is relocated to the URL page specified by defaultredict, displaying a friendly error message for the user.
Through the right. NET provides the analysis of the above four error handling mechanisms, we can classify them from different angles, which is easy for us to understand and use.
1, from the functional classification: for exception handling (handling Exceptions) is Page_Error events and Application_Error events; User error page redirection (redirecting the user to an error Page) is the ErrorPage property and the <customErrors> configuration item.
2. Classification from error Handling: For page level error handling is the Page_Error event and the ErrorPage property; for application-level error handling Application_Error events and <customErrors> configuration items.
These asp.net modules do not only deal with ASP.net web programs, but also with other ASP programs, PHP programs, or static HTML pages, and since ASP.net's many features have become part of IIS 7, ASP programs, PHP programs, or static HTML Web pages and other types of requirements, you can also use ASP.net 2.0 features such as Forms authentication (forms authentication) or output caching (for export cache) (but you need to modify the settings for IIS 7). Also because IIS 7 allows you to develop and join modules by itself with the ASP.net API, it is easier for asp.net web developers to expand the functionality of IIS 7 and Web site applications, and even write programs that manage IIS 7 on their own. NET (for example, program-controlled IIS 7 to build a Web site or Virtual directory)
Execution architecture diagram for IIS 7 (schema in integrated managed channel mode)
Summary
The improvement of IIS5 to IIS6 is mainly the improvement of HTTP.sys.
The improvement of IIS6 to IIS7 is mainly the improvement of ISAPI.