Upgrading from Helicon ISAPI Rewrite to Microsoft URL Rewrite Module for IIS7
Helicon ISAPI Rewrite has been used for years in Orangium to rewrite urls, and remove ASPX extensions. To this day, it is still the best way of rewriting urls in IIS6. It is also working fine for IIS7 / IIS7.5. However, after getting some problems on Windows 7 SP1, we had to make the obvious move to start using the native Microsoft URL Rewrite Module for IIS7. We now support both modules.
To start using Url Rewrite Module for IIS7, download and install the module, and add this rule to the web.config file, in the configuration section.
2 <system.webServer>
3 <rewrite>
4 <rules>
5 <rule name="Fail bad requests">
6 <match url=".ico"/>
7 <conditions>
8 <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
9 </conditions>
10 <action type="AbortRequest" />
11 </rule>
12 <rule name="RewriteASPX" stopProcessing="true">
13 <match url="^([^/]+)/?$" />
14 <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
15 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
16 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
17 <add input="{URL}" negate="true" pattern="\.axd$" />
18 </conditions>
19 <action type="Rewrite" url="{R:1}.aspx" />
20 </rule>
21 </rules>
22 </rewrite>
23 </system.webServer>
To make sure Url Rewrite Module is properly installed, open IIS Manager and check for the new icon, as shown here :

1 string originalUrl = "";
2
3 // get original url using helicon isapi rewrite http://www.isapirewrite.com/
4 originalUrl = HttpContext.Current.Request.ServerVariables["HTTP_X_REWRITE_URL"] + "";
5
6 if (originalUrl == "")
7 {
8 // get original url using IIS7 http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
9 originalUrl = HttpContext.Current.Request.ServerVariables["HTTP_X_ORIGINAL_URL"] + "";
10 }
11
12 if (originalUrl != "")
13 {
14 originalUrl = originalUrl.Substring(1);
15 }

Commentaires