tags:

views:

190

answers:

1

The problem is as follows:

I have an HttpHander, which works completely fine in IIS 6.0 (it's configured throught Web.Config)

   <add verb="*" path="MyHandlder" type="MyNamespace.MyHandler"/>

But when i'm trying to access it via url (http://localhost/MyHandlder?somevar=somevalue), it gives me "Page cannot be found" error, even thou the names are definately correct (works for IIS 6.0).

Thank you for hints.

UPD: The problem is ONLY for cases when path is without an extension. path="MyHandler.myExt" works fine. Is there ANY way to configure IIS 5.1 to handle handlers without an extension?

+1  A: 

EDIT: Below the line is my original answer. I hadn't spotted that you said it was working for you on IIS 6... that's not been my experience in the past!

I would check your IIS 6 configuration and see if there's any special URL rewriting (or similar) set up.


Basically IIS is trying to find that as if it's a directory, because it doesn't have a file extension. I believe it treats everything without a file extension as a directory, and handles it itself - at least by default.

As annakata says in the comments, you can add "wildcard" handling via ASP.NET in IIS. This isn't something I've tried, and it sounds frankly dangerous (in terms of undesired consequences), but there are step-by-step instructions on Chris Love's blog.

Another option may be to do something with URL rewriting (not in ASP.NET, but for IIS itself), but if at all possible I'd suggest you map your handler to a path containing a file extension. If you use a file extension which isn't handled by ASP.NET already, you'll have to add that into the list of ISAPI filters.

I only know all of this because I tried to do something very similar for my Wave Robot API. You may want to look at my SO question and the answers for more information. Check the comments to the accepted answer in particular.

Jon Skeet
One hesitates to question the master, but is this not more likely that IIS does not push the request through the ASP.NET pipeline given the lack of a file extension? Hence no amount of coding will solve this, but binding wildcard handling to ASP.NET will (though whether that's a good idea is dubious)
annakata
@annakata: I think we're in violent agreement. As I say, it's trying to just treat it like a directory rather than passing it through to ASP.NET. I don't know how you'd do bind wildcard handling to ASP.NET though... I couldn't when I experimented, but I'm a novice on this.
Jon Skeet
Hah, quite likely! Well it's done through IIS - don't have one handy, but this link covers the idea for IIS6 (http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx)
annakata
annakata: Mind if I move that into the answer then?
Jon Skeet
(Have done so; will roll back if you'd rather add your own answer instead.)
Jon Skeet
the problem is definately that the path doesn't have an extension. as far as i add path="MyPath.ashx" and access it through this, it's fine... but how to configure it to work my way? ))
ifesdjeen
(meh, you keep it) afaik it isn't dangerous *per se* but it is very heavy on the processor and not something you'd want to do if you could help it. Long story short, yeah the OP should change his path extension (and just get on MVC)
annakata
@opetrov - only way I know is wildcard binding as per the link, but surprised this works in IIS6 for you. Suggest you check the site in 6 and see if that *does* have wild binding
annakata
it does for 6. it works completely fine. truly.
ifesdjeen