简体   繁体   中英

HTTP Handler works using Cassini, but not with IIS 6

I've created a sample project to simplify my problem. I have this simple handler:

public class HandleThis : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest( System.Web.HttpContext context )
    {
        // Score.aspx just says "success"
        context.Response.Redirect( "Score.aspx" );
    }

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

Then, in my config, I have this:

<httpHandlers>
<add verb="*"
path="Survey"
type="HttpHandlerTest.HandleThis, HttpHandlerTest" />

Now when I hit http://server/Survey my handler fires.

If I change my project to run with IIS 6, it won't fire (404). I tried manually adding the handler in IIS via: - Web Site Properties - Home Directory - Configuration - Add (browse to my site's .dll), Extension: Survey, uncheck "Verify that file exists"

I notice that IIS (so helpfully) adds the "." in front of my extension, so I hit the site with "b.Survey"; still 404.

Surely it's possible to add a handler in IIS 6?

"I tried manually adding the handler in IIS via: - Web Site Properties - Home Directory - Configuration - Add (browse to my site's .dll), Extension: Survey, uncheck Verify that file exists"

It sounds like you're using the wrong "executable" path. The executable path should point to the aspnet isapi dll, not the dll that contains your HttpHandler implementation.

Try using the same path that the .aspx extension is mapped to (often this is: c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_isapi.dll).

In Cassini everything goes through your dev server, even though the programming in the server will throw an exception if you try to use it in integrated mode.

In IIS7 it would work, if you are running the application in integrated mode.

In IIS6 you either have to assign path="*" to ASPNET_ISAPI.dll and then have the same quoted code as above in your web.config, or you have to assign the extension in the path for your handler.

If you're having trouble adding the aspnet isapi as * in IIS6, google for "extensionless IIS6" or something similar for step-by-step tutorials.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM