Reputation: 2808
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
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.
Upvotes: 0
Views: 1038
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