February 28, 2006
@ 01:43 PM
It's more than 1 year that I'm using URL rewriting in my web application projects to make pages adresses more friendly. Before ASP.NET 2.0 release and its URL Mapping feature, web developers had to write their own Http Handlers to perform a complete URL rewriting solution. Scott Mitchell had written a good HttpHandler for URL rewriting in ASP.NET 1.x which published on MSDN as a technical article.

For its time, this tool was good enough because it let developers use regular expression to rewrite URLs. One major problem that developers may face while using this tool is "Not Available Folders" rewrite rules. Imagine you want to rewrite a path like this: ~/News/2005/ to ~/News/Default.aspx?Year=2005. It is a good idea to let visitors hack your URLs. But if you don't have a real 2005 folder and a default.aspx file inside it, IIS will return a 404 error page. In such cases we have two solutions: 1- Make a dummy folder for such URLs. 2- Map all incoming requests to ASP.NET engine. It's clear that first solution is not suitable because you should make a new folder on the fly for a record that is added in 2006! And also the second is not a good idea because we should handle all extensions manually. As Scott said on his blog (and on MSDN article), .Text (and Community Server I guess) use a solution similar to our second option but unfortunately I didn't check them so far.

It's my story these days!! If you faced this problem too and have solutions please discuss on it in the comments. (Specially, if you have worked on .Text or CS source codes you may know more about their solutions. So as Soheil says on iDevCenter "Share Your Knowledge" !!!)


UPDATE [3/2/2006]: There is another solution for those who have access to web server. IISMods.com offers an open-source free ISAPI filter for IIS that let you perform URL Rewriting at the web server level. But this solution is not suitable for shared server hosting packages. So I won't use it!


 


Tuesday, February 28, 2006 2:21:28 PM (Iran Standard Time, UTC+03:30)
Dear Mehdi, I have used .Text solution myself in many web projects and it worked! I recommend you to focus on it. I have not any look on their recent CS, so you may find a better solution in CS 2.0.
Tuesday, February 28, 2006 5:12:02 PM (Iran Standard Time, UTC+03:30)
Look at this pack. I think that it's useful:
http://www.urlrewriting.net/en/Download.aspx
Shortly, In CS 2.0, they have 2 ways to handle this problem:
1- TinyURL Module: Which is used to make the Urls shorter.
2- Url Module: Which does Url reqwriting and contains these steps:
A- In some cases uses a Auto Folder Creation to generate those dummmy folders.
B- A HTTP Module to handle Url Rewriting as an engine.
Friday, March 03, 2006 6:14:33 AM (Iran Standard Time, UTC+03:30)
You may use another Virtual Directory inside your main ones so that you handle everything using ASP.NET. As far as I know, the only way you can handle folders virtually is handling *.* with ASP.NET, so by creating a seprate Virtual Directory, it will be effortless handling the matters.
Comments are closed.