How do I add an HttpHandler to the web.config?
Asked Answered
D

2

16

I wrote a httphandler to handle all XSLT requests.

The name of the handler is XSLTHandler.cs.

web.config

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

I got this error message, dont know how to fix it.

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load type 'XSLTHandler'.

Dropforge answered 23/10, 2011 at 23:53 Comment(0)
H
21

What you're missing is the assembly and namespace that XSLTHandler belongs in, from MSDN. So if it's located in your current project, it should look like this:

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.xsl" 
        type="WebApplicationName.XSLTHandler, WebApplicationName" />
    </httpHandlers>
  </system.web>
</configuration>
Haggerty answered 23/10, 2011 at 23:55 Comment(1)
A short note for any VB-ers landing here from a search provider: the namespace and classname are case-sensitive.Gaylord
S
5

The MSDN link shows how to configure for both the classic and integrated modes

https://msdn.microsoft.com/en-in/library/ms228090(v=vs.80) Note that you need to provide the proper namespace of the handler you are using

Example:

<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>
Sure answered 5/10, 2017 at 12:40 Comment(1)
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.Beaird

© 2022 - 2024 — McMap. All rights reserved.