Archive for category URL Rewriting

IIS Express hanging when launched from visual studio

I recently built up a new machine at work and grabbed all my latest projects out of SVN only to find that one of them no longer seemed to start.

Since checkout I hadn’t changed any code, got a clean build, but when the browser window opened it just hung, with no error.

I eventually found this was because I was using the UrlRewrite module on the site (with the rules in the web.config file) but had forgotten to install this component on my IIS on the new machine. An error message would have been nice!

No Comments

IIS7 UrlRewrite Outbound links with Compression Enabled

I’ve recently started using the outbound link rewriting feature in the url rewrite module for IIS7, but initially ran into some problems.

In my web.config, my rewrite section (under system.webServer) looked something like this;

        <rule name="InboundFriendlyAboutUs" stopProcessing="true">
          <match url="^about-our-car-finance$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          <action type="Rewrite" url="About-Us.aspx" />
        <rule name="OutboundFriendlyAboutUs" preCondition="IsHtml">
          <match filterByTags="A, Form" pattern="^(.*)About-Us\.aspx$"/>
          <action type="Rewrite" value="{R:1}about-our-car-finance"/>
          <preCondition name="IsHtml">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>

However when I tried to view the page I received a server error;

HTTP Error 500.52 – URL Rewrite Module Error.
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded (“gzip”).

This is because I also had the IIS7 dynamic and static compression enabled, as is sensible for any website. It turns out that, while dynamic compression is supported, static is not- and dynamic requires a little bit of fiddling to get going. I’ll boil it down to a few steps;

  1. On the machine running the web site, from the command line run:
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v LogRewrittenUrlEnabled /t REG_DWORD /d 0
    You may need to follow this up with an iisreset
  2. Add the following to the top of your system.webServer section of your web.config file to disable the unsupported static compression while leaving dynamic unharmed;

    <urlCompression doStaticCompression=”false” doDynamicCompression=”true” dynamicCompressionBeforeCache=”false” />

  3. The final step, is probably not needed- but! Open up your IIS management console- Click on the top level item, from the IIS segment open the “Modules” component. From within here on the right hand side bar, click “View ordered List…” and make sure RewriteModule appears in the list BELOW the DynamicCompressionModule. For me, this was already the case- my RewriteModule appeared at the very bottom, but this may not be the case for you.

If you’re after more details- my source was here;

6 Comments aspx pages posting back to the wrong URL when using Server Rewrite

Had a problem today working on a new phase of one of our existing sites (a problem which I’m sure I came up against on another site and fixed a few years ago…) – we just added server rewrite with a whole new URL structure like so; group name/ series name/ book.htm

This allows the user to chop off a folder and get back to the relevant listing page- pretty standard stuff now days.  So this introduces a bunch of virtual folders.  All the sites resources were set to use absolute paths and everything was loading in and rendering fine, but the page crashed every time I click the “Add to cart” button– bit of a show stopper.

This was because dot net isn’t aware of the rewrite- so while they hit the site on a url like;

childrens-books/beast-quest/book1.htm thought the page was at


so did a post back to that page, relative to the current folder, giving me;


trying to reference the physical file (which existed at the root level) from the context of a folder which doesn’t really exist.  The fix is easy (once you find it!) – for this site the main form tag was in the masterpage so I just added the following to the Page_Load of my master page;

form1.Action = Request.RawUrl;

Thanks to Ruslan Yakushev’s post on

No Comments