Hithere Paperbag
Hithere Paperbag

Reputation: 2808

Where do I put the dll when I've compiled a httphandler into a class?

I have a httphandler that I got from msdn, looks this way

using System.Web;
public class HelloWorldHandler : IHttpHandler
{
    public HelloWorldHandler()
    {
    }
    public void ProcessRequest(HttpContext context)
    {
        HttpRequest Request = context.Request;
        HttpResponse Response = context.Response;
        // This handler is called whenever a file ending 
        // in .sample is requested. A file with that extension
        // does not need to exist.
        Response.Write("hello"); 


    }
    public bool IsReusable
    {
        // To enable pooling, return true here.
        // This keeps the handler in memory.
        get { return false; }
    }
}

So I compiled it to Handler.dll and put it in C:\inetpub\wwwroot\Handler

I then added this Web.config file

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.abc" 
        type="HelloWorldHandler", "HelloWorldHandler" />
    </httpHandlers>
  </system.web>
</configuration>

and put it in C:\inetpub\wwwroot\Handler also

enter image description here

I thought with this then I could go to http://localhost/Handler/page.abc and the handler would intercept the request, but this doesn't go this way? I suspect it is maybe the .config file? Please help.

enter image description here

Upvotes: 0

Views: 1038

Answers (1)

daryal
daryal

Reputation: 14919

Your configuration is not proper, you need to add the namespace of the class to the type and also declare the handler dll, change the type node;

<configuration>
  <system.web>        
<system.webServer>
    <handlers>
        <add verb="*" path="*.abc" name="HelloWorldHandler"
        type="HelloWorldHandler" />
    </handlers>
</system.webServer>
  </system.web>
</configuration>

Upvotes: 1

Related Questions