【问题标题】:How do I add an HttpHandler to the web.config?如何将 HttpHandler 添加到 web.config?
【发布时间】:2011-12-13 18:50:44
【问题描述】:

我写了一个httphandler 来处理所有 XSLT 请求。

处理程序的名称是XSLTHandler.cs

web.config

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  <httpHandlers>
    <add verb="*" path="*.xsl" type="XSLTHandler" />
  </httpHandlers>
  </system.web>
</configuration>

我收到此错误消息,不知道如何解决。

配置错误说明:在安装过程中发生错误 处理服务此请求所需的配置文件。 请查看下面的具体错误详细信息并修改您的 配置文件。

解析器错误消息:无法加载类型“XSLTHandler”。

【问题讨论】:

    标签: asp.net web-config httphandler ihttphandler


    【解决方案1】:

    您缺少的是 XSLTHandler 所属的程序集和命名空间,from MSDN。因此,如果它位于您当前的项目中,它应该如下所示:

    <configuration>
      <system.web>
        <httpHandlers>
          <add verb="*" path="*.xsl" 
            type="WebApplicationName.XSLTHandler, WebApplicationName" />
        </httpHandlers>
      </system.web>
    </configuration>
    

    【讨论】:

    • 对于任何从搜索提供程序登陆的 VB 用户的简短说明:命名空间和类名区分大小写。
    【解决方案2】:

    MSDN 链接显示如何配置经典模式和集成模式

    https://msdn.microsoft.com/en-in/library/ms228090(v=vs.80) 请注意,您需要提供正在使用的处理程序的正确命名空间

    例子:

    <configuration> 
    <system.web>
    <!--Classic-->
    <httpHandlers><add verb="*" path="*.sample" name="HttpHandler" type="Handler.kHttpHandler"/></httpHandlers>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    </system.web>
    
    <system.webServer>
    <!--Integrated mode-->
    <handlers><add verb="*" path="*.sample" name="HttpHandler" type="Handler.kHttpHandler"/></handlers>
    </system.webServer>
    </configuration>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    相关资源
    最近更新 更多