views:

786

answers:

3

I've got an HTTP handler set up in the web.config file:

        <add verb="*" path="*_*.aspx" type="SeoHandler"/>

And have a file SeoHandler.ashx in the root of my web site that points to a SeoHandler.ashx.cs in the App_Code folder (the web site isn't a Web Application project).

When I run the site locally and type in a URL like "dork_test.aspx", the request is redirected to the handler where it then takes care of business.

But when the compiled site is running on my domain, "dork_test.aspx" will result in:

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /dork_test.aspx

Why would SeoHandler catch the "dork_test.aspx" request locally but not on the server?

Not sure if this matters, but when I hit the URL SeoHandler.ashx on my domain, the handler works like it's suppose to.

Is it possible that the web host has some IIS setting that ignores my entry in <httpHandlers>?

+1  A: 

I am able to get it to work on IIS 7. Are you using a shared hosting provider that have something like URLScan installed? Can you see if there are non-default settings at the server level?

Colin Bowern
+6  A: 

Check in IIS on the server that the .NET handler is not set to verify the requested path physically exists:

  • Go to Properties of the web site or virtual directory
  • Home Directory tab
  • Click "Configuration" in the lower section
  • Find the extension for .ASPX and click edit, there is a checkbox that says "Verify that file exists".

If that checkbox is checked, .NET will not serve any requests that don't map to a physical file in the same location.

Rex M
Damn, all the admins for my hosting company are gone until monday. Ugh. I'll direct them there when I can get a hold of them. Thanks Rex!
Chris
@Chris appreciate it, but you should probably wait to accept my answer after you've confirmed with your admins this is the problem :)
Rex M
+1 It's late. My deployment's gone wrong. Unchecked "Verify file exists" - success! Im off to bed.
Dead account
A: 

Hi,

Rex M's got the right answer but I just tried something similar to handle .jpg and it failed.

The checkbox that says "Verify that file exists" is very important but still you have a issue with the Authorization for that folder.

I then tried to change the new web.config that I added for that folder and added

    <authorization>
                       <allow users="*" />
    </authorization>

And it worked. So there is something going on with the Authorization process that doesn't let me handle the .jpg requests. And yes, I am authenticated in that app and It still fails if I try to request a .jpg.

Hope this solves to prove that your Handler works fine but that for that you need to had a major security issue...

Txugo