HttpHandler Not Working

ScottMacMaster
ScottMacMaster used Ask the Experts™
on
I've never setup a HttpHandler before. What've I done isn't working. Can someone help? The following is what I've done.

1. Created a ClassLibrary project called TestHandler.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace TestHandler
{
    public class TestHandler : IHttpHandler
    {
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.Write("test");
        }

        public bool IsReusable{get {return true;}}
    }
}

End Class

2. Copied the .dll into c:/windows/system32/inetsrv/

3. Added a virtual directory to the web site

I named it TestHandler.

4. Added .test extension to web app.

Went into the properties for the web app. Under Virtual Directory/Application settings I went into Configuration. The added an extension. I selected my dll, typed in .test, selected All Verbs.  This will eventually be used to process images so I think I'll only need to use GET.

5. Referenced the dll in a web.config file.

I created an empty web project to create a default web.config file. Then, I added a httphandler to it.

    <system.web>
        <httpHandlers>
            <add verb="*" path="*.test" type="TestHandler, TestHandler.TestHandler " validate="true"/>
        </httpHandlers>

I then copied the web.config file to the folder for the web app.

6. Tested it

I created an empty file named test.test.

I then tried to open the file in my web browser. My browser gave the error "The Page Cannot Be Found"

The url to the test page is, http://itservices.bc3.edu/TestHandler/test.test

You can change .test to .html to see the test web page I have their.


Can someone help me get this working?
Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
1st. the file that you select when you add that .test extention should be:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

2. You need to uncheck the "Verify File Exists" option when you added the extention

3. The dll should be in the bin folder.

Author

Commented:
Thanks, I missed that detail about mapping the extension to ASP.NET when I was looking at some references I found on the internet.

What's the reason for unchecking "Verify File Exists"?

I created a bin folder and put my dll in it.  That got it working.  I assume that ASP.NET looks there by default for assemblies?

Thanks,

Commented:
Yes, by default it looks in the bin

Additionally, you didn't need to add this to the extension path? "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"

Verify if file exists means to verify if there is a physical file there

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial