ASP.NET httpHandlers和处理程序

Xin*_*Xin 5 asp.net asp.net-mvc

我对httpHandlers system.web和处理程序感到困惑system.webServer.这两种配置有什么区别?以及如何以及何时使用它们?

实际上另一个问题也是模块:httpModules in system.web和modules insystem.webServer

Moh*_*deh 5

Web.config文件中的system.webServer部分指定应用于Web应用程序的IIS 7.0设置。system.WebServer是配置部分的子级。有关更多信息,请参见IIS 7.0:system.webServer节组(IIS设置架构)。

<system.web>指定ASP.NET配置部分的根元素,并包含用于配置ASP.NET Web应用程序并控制应用程序行为的配置元素。httpHandlershandlers一样。

要为IIS 6.0注册HTTP处理程序,应使用:

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="SampleHandler.new" 
        type="SampleHandler, SampleHandlerAssembly" />
    </httpHandlers>
  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

要为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>
Run Code Online (Sandbox Code Playgroud)

在这里阅读更多