zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

WebConfig的httpHandlers配置后不执行-解决方案

2023-09-11 14:14:50 时间

网上找的例子发现都是写在 system.web里面

<system.web>
  <httpModules>
           <add name="TestModule" type="ClassLibrary831.TestModule,ClassLibrary831"></add>
  </httpModules> 

 <httpHandlers>
       <add verb="*" path="*" type="ClassLibrary831.TestHandler,ClassLibrary831"></add>
  </httpHandlers> 

</system.web>

结果发现不执行

就在网上找了好久,发现.net framework 4.0 版本的程序httpHandlers是写在system.webServer里面

 <system.webServer>
    <modules>
      <remove name="TelemetryCorrelationHttpModule"/>
      <add name="TelemetryCorrelationHttpModule"
        type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation"
        preCondition="integratedMode,managedHandler"/>
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <add name="ClassLibrary831" verb="*" path="cc.cc" type="ClassLibrary831.TestHandler,ClassLibrary831"></add>
    </handlers>
  </system.webServer>

需要注意的是

在 system.webServer里面的httpHandlers,

只能写<handlers></handlers>,

并且还得有name属性

 

感谢

https://blog.csdn.net/jiidd/article/details/82019259

https://www.cnblogs.com/chenlulouis/archive/2009/12/18/1626918.html