2015-06-15 19 views
4

我對system.web中的httpHandlers和system.webServer中的處理程序感到困惑。這兩種配置有什麼區別?以及如何以及何時使用它們?ASP.NET httpHandlers&handlers

其實另一個問題是模塊以及:在的HttpModules和system.web模塊system.webServer

回答

4

在Web.config文件中的system.webServer節指定應用到Web應用程序IIS 7.0的設置。 system.WebServer是配置部分的子節點。有關更多信息,請參閱IIS 7.0:system.webServer部分組(IIS設置架構)。

<system.web>指定了ASP.NET配置部分的根元素,幷包含配置ASP.NET Web應用程序並控制應用程序行爲方式的配置元素。 httpHandlers & handlers是相同的。

要註冊IIS 6.0中使用HTTP處理程序應該:

<configuration> 
    <system.web> 
    <httpHandlers> 
     <add verb="*" path="SampleHandler.new" 
     type="SampleHandler, SampleHandlerAssembly" /> 
    </httpHandlers> 
    </system.web> 
</configuration> 

要註冊IIS 7.0中使用的HTTP處理程序應該:

<configuration> 
    <system.web> 
    <httpHandlers> 
     <add verb="*" path="SampleHandler.new" 
     type="SampleHandler, SampleHandlerAssembly" /> 
    </httpHandlers> 
    </system.web> 
    <system.webServer> 
    <add name=SampleHandler" verb="*" path="SampleHandler.new" 
     Modules="IsapiModule" 
     scriptProcessor="FrameworkPath\aspnet_isapi.dll" 
     resourceType="File" /> 
    </system.webServer> 
</configuration> 

更多Here

1

<system.web>是asp.net的配置部分,傳統上這是你定義你的httpHandlers和httpModules的地方。

隨着IIS 7(2007)的推出,web服務器和asp.net得到了更多的集成,並引入了全新的IIS配置系統。

作爲其中的一部分用於處理器和模塊定義的位置。如果你還在使用IIS6被轉移到<system.webServer>

(停止),或在IIS7使用經典管道模式+您需要在您的定義<system.web>下,如果您在IIS7 +中使用集成管道模式將它們置於<system.webServer>之下。你不應該在兩個部分都有他們。