views:

887

answers:

2

I wrote a custom URL rewriting module, to take certain paths and map them to our catalog out of the database.

I am using the technique outlined in the link at the bottom of my post.

I'm using .NET 3.5. The problem is that it only works when there is a page name on the end of the original URL, but if the page name is left off, then it never even calls my handler. So for example, the URL

http://mysite.com/folder/index.aspx  works but 
http://mysite.com/folder/            does not. 

The one with just the folder never gets into my handler class at all. Is there something you need to do to enable folders to work properly?

http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/

A: 

I'm not sure how to solve it but the reason is becaus IIS is treating it as a directory (which it is) and doesn't have any knowledge about how to pass the folder to the ASP.NET isapi filter and trigger the .Net handler.

You could try doing it with IIS7 and inserting the handler in the actuall IIS pipeline. Or check the bottom of the article you referenced below the heading "Using RewriteModule".

David McEwing
Well, I have it in my HttpModules section already as he specifies. The only thing i could see is adding the ISAPI filter; but since that goes by extension, I'm not sure how I would add "folders" to the ISAPI handlers list. It must be possible somehow, given that that is precisely what he uses the code for, in the example of the blog post parameters.
eidylon
A: 

Is a know issue when using .NET rewriting. You need to correctly configure the wildcard mapping. Here is a good link:

http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx

Another option will be rewriting by IIS ISAPI with regular expressions. In my company we actually use both.

Check out this link for references:

http://www.kowitz.net/archive/2006/09/15/url-rewriting-using-ihttpmodule-vs-isapi-rewrite.aspx

Lucas
ISAPI looks like what I would need I guess. The '*' file mapping in IIS doesn't seem to work. The server is a Server 2003 R2 box, with the older IIS (pre-Vista look), and does not allow adding an extension of just '*' (says bad extension format). This sounds like it adds quite an overhead too, processing ALL files through the asp dll. Do you have links to writing ISAPI's in .NET? Can this be done as a file in the web project, or does it need to be compiled into a separate dll?Thanks in advance.
eidylon
I thought this link looked promising, but it looks like it would just suffer from the same wildcard mapping problem: http://codebetter.com/blogs/karlseguin/archive/2006/05/24/145397.aspx .
eidylon
Here is an open source: http://www.codeplex.com/IIRFBut... When you use ISAPI you send all the request to the isapi dll.... Using a .net dll it generate the same overhead for ISAPI and for aspnet_isapi.I still dont know way you cant configure the wildcards:http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/
Lucas
Yah, I don't know why either. I missed the special wildcards section in the mappings dialog earlier, but now i just tried adding it in, and it still didn't work. Time to just accept adding ".aspx" to the end of all my dynamic urls and move on. Thanks for the ideas though; they look right, just not working on our server for some reason.
eidylon