我們將ASP.NET程序從IIS6移植到IIS7,可能運行提示以下錯誤:
HTTP 錯誤 500.23 - Internal Server Error
檢測到在集成的托管管道模式下不適用的 ASP.NET 設置。
為什么會出現以上錯誤?
在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"),是不會產生錯誤的。
