1. 程式人生 > >檢測到在集成的托管管道模式下不適用的ASP.NET設置的解決方法(轉載)

檢測到在集成的托管管道模式下不適用的ASP.NET設置的解決方法(轉載)

blank span 轉載 sdn 是我 module error conf str

我們將ASP.NET程序從IIS6移植到IIS7,可能運行提示以下錯誤:

HTTP 錯誤 500.23 - Internal Server Error

檢測到在集成的托管管道模式下不適用的 ASP.NET 設置。

為什麽會出現以上錯誤?

在IIS7的應用程序池有兩種模式,一種是“集成模式”,一種是“經典模式”。

經典模式 則是我們以前習慣的IIS 6 的方式。

如果使用集成模式,那麽對自定義的httpModules和httpHandlers 就要修改web.config配置文件,需要將他們轉移到<modules>和<hanlders>節點裏去。否者集成模式會認為你將自定義的httpModules和httpHandlers錯誤地放在了經典模式的<system.Web>節點下了,就會像上面這樣報錯提醒。當然後我們也可以通過web.config中的validateIntegratedModeConfiguration選項來關閉集成模式檢查,避免這個報錯,本文後面會講這個設置。

第一種方法、配置應用程序池

在IIS7上配置應用程序池,並且將程序池的模式改為“經典”,之後一切正常。如圖:

技術分享圖片

在搜索引擎輸入上面提示的錯誤消息,搜索到的結果幾乎都是直接改為“經典”便淺嘗輒止了。

但這樣只是權宜之計,用了IIS7.x,但實際只發揮了6的功能,另外,在一些ASP.NET MVC程序中的效果也不好,所以,我們嘗試以下解決方法:

第二種方法、修改web.config配置文件:

例如原先設置(你的環境中可能沒有httpModules,httpHandlers節點)

<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> </system.webServer>

當然你也可以同時在<system.Web>和<system.webServer>中註冊你的httpModules和httpHandler來兼容IIS6和IIS7的設置,如下所示:

<system.web>

    <httpModules>
        <add name="MyModule" type="MyApp.MyModule" />
    </httpModules>
    <httpHandlers>
      <add path="*.myh" verb="GET" type="MyApp.MyHandler" />
    </httpHandlers>
</system.web>

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <modules>
      <add name="MyModule" type="MyApp.MyModule" />      
    </modules>
    <handlers>
      <add name="MyHandler" path="*.myh" verb="GET" type="MyApp.MyHandler" preCondition="integratedMode" />
    </handlers>

</system.webServer>

但是註意這樣的話要將<system.webServer>下的validateIntegratedModeConfiguration選項設置為false,告訴IIS 7不要去檢查<system.Web>下的<httpModules>和<httpHandlers>節點,來避免錯誤。

原文鏈接

檢測到在集成的托管管道模式下不適用的ASP.NET設置的解決方法(轉載)