IIS7的Application Pools有两种mode,一种是Integrated,一种是classic。如果使用Integrated模式,那么对自定义的httpModules和httpHandlers就要修改配置文件了,需要将他们转移到<modules>和<hanlders>节里去。
IIS7的两种模式和IIS6有什么区别?
IIS7.0 Integrated mode:asp.net 的modules和handlers从<system.webServer>下的<modules>和<handlers>里读取,以前的<system.web>下的<httpModules>和<httpHandlers>配置节会被忽略,如果设置禁止验证(disabledvalidation),是不会产生错误的。
IIS7.0 Classic mode: 与 以上情况是相反的,<modules>和<handlers>会被忽略。
Classic vs Integrated
Classic mode (the only mode in IIS6 and below) is a mode where IIS only works with ISAPI extensions and ISAPI filters directly. In fact, in this mode, Asp.net is just an ISAPI extension (aspnet_isapi.dll) and an ISAPI filter(aspnet_filter.dll). IIS just treats Asp.net as an external plugin implemented in ISAPI and works with it like a black box (and only when it's needs to give out the request to ASP.NET). In this mode, Asp.net is not much different from PHP or other technologies for IIS.
经典模式是IIS6.0以及以下版本的唯一工作模式(只工作在ISAPI EXTENSION,ISAPI FILTERS下)。在此种模式下asp.net只是一个分别实现了ISAPIEXTENSION和ISAPI FILTER的插件(aspnet_isapi.dll,aspnet_filter.dll),IIs的工作只是将特定的请求转发给Asp.net,与PHP等等寄宿在IIS中的插件别无二致。
Integrated mode, on the other hand, is a new mode in IIS7 where IIS pipeline is tightly integrated (i.e. is just the same) as Asp.net request pipeline. ASP.NET can see every request it wants to and manipulate things along the way. ASP.NET is no longer treated as an external plugin. It's completely blended and integrated in IIS. In this mode, Asp.net HttpModules basically have nearly as much power as an ISAPI filter would have had and Asp.net HttpHandlers can have nearly equivalent capability as an ISAPI extension could have. In this mode, Asp.net is basically a part of IIS.
然而在集成模式里,IIS的管道与Asp.net的请求管道是紧密集成的,Asp.net可以完全控制,访问整个请求管道。Asp.net不在作为一个外部插件,而是完全集成在IIS中。在此模式下,Asp.net HttpModules与ISAPI Filter拥有等同的控制权,Asp.net HttpHandlers与ISAPI Extension拥有等同控制权,换而言之Asp.net已经是IIS的一部分了。
如果要兼顾IIS6及IIS7,可在web.config中同时保留httpHandlers(for IIS6)及handlers(for IIS7)里的相同定义,但记得要加上<validation validateIntegratedModeConfiguration="false" />,不然IIS7会因为定义重覆出现而发生错误。