检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(转) |
我们将ASP.NET程序从IIS6移植到IIS7,可能运行提示以下错误:
为什么会出现以上错误? 在IIS7的应用程序池有两种模式,一种是“集成模式”,一种是“经典模式”。 经典模式 则是我们以前习惯的IIS 6 的方式。 如果使用集成模式,那么对自定义的httpModules 和 httpHandlers 就要修改配置文件,需要将他们转移到<modules>和<hanlders>节里去。 两种解决方法: 第一种方法、配置应用程序池 在IIS7上配置应用程序池,并且将程序池的模式改为“经典”,之后一切正常。如图: 第二种方法、修改web.config配置文件 例如原先设置 <system.web> ............ <httpModules> <add name="MyModule" type="MyApp.MyModule" /> </httpModules> <httpHandlers> <add path="*.myh" verb="GET" type="MyApp.MyHandler" /> </httpHandlers> </system.web> 在IIS7应用程序池为“集成模式”时,改为 <system.web> ........... </system.web> <system.webServer> <modules> <add name="MyModule" type="MyApp.MyModule" /> </modules> <handlers> <add name="MyHandler" path="*.myh" verb="GET" type="MyApp.MyHandler" preCondition="integratedMode" /> </handlers> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> 如果想保留原先设置,更改后可以设置禁止验证集成模式(validateIntegrateModeConfiguration="false"),是不会产生错误的。 |