Feed on
Posts
Comments

URL Rewriting under IIS

Since I’m an ASP.NET developer I’ll share my experience with URL rewriting options that I have tried in mine, guess what, ASP.NET web sites. So far I know three options to do this task:

  • ASP.NET 2.0 Mapping
  • Using UrlRewritingNet.UrlRewrite
  • Using ISAPI Rewrite filter - this is the most powerful option.

 

ASP.NET 2.0 URL Mapping

The build in URL mapping has really limited features. It can only rewrite static URLs to other static URLs.

To use the URL mapping you need to add the rewriting rules in the in the section of the web.config file:

<system.web>
    <urlMappings enabled="true">
        <add url="~/home.aspx" mappedUrl="~/default.aspx"/>
    </arlMappings>
</system.web>

So if the user types in the browser address bar the URL http://www.mysite.com/home.aspx the request will be handled by the default.aspx page.

I assume that Microsoft will not put much an effort to extend the features of URL Mapping since IIS 7.0 will support URL Rewriting. Anyway in some cases this could be useful so I’m happy to have this option.
 

Using UrlRewritingNet.UrlRewrite

This is an open-source component for ASP.NET 2.0. It is a really cool tool, and although it is open-source project, it has good support in its forum. And of course it has a disadvantage – it is appropriate only for rewriting numbers or text that do not contain any special characters like “<” for example. And this is normal because the component is being activated after the IIS has done his job, and we all know that IIS does not like special symbols and returns “Bad file name” error.

The rewriting rules are located in the web.config file.

You can find it here: http://www.urlrewriting.net
 

Using ISAPI Rewrite filter

So far this is the best option that I know. I’m using the paid ISAPI filter of HeliconTech that has to be installed on the server. The price is small, the features are big, so it’s totally worth it. The filter will handle any special symbol without any problem, thus preventing the “Bad file name” error returned by IIS. This is very useful when you want to put text in the URLs – for example the usernames of the members of your web site.

The rewriting rules are located in a simple INI file named httpd.ini. This file should be located in the web site root folder. If you use Windows XP the root folder of the Default Web Site is usually C:\Inetpub\wwwroot.

You can find it here: http://www.isapirewrite.com/

, , , ,
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

Trackback URI | Comments RSS

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a