简体   繁体   中英

ASP.NET URL rewriting not working with folder URLs

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/

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

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".

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