<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shawson&#039;s Code Blog &#187; URL Rewriting</title>
	<atom:link href="http://codeblog.shawson.co.uk/category/iis/url-rewriting/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeblog.shawson.co.uk</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Wed, 01 Feb 2012 11:00:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>IIS Express hanging when launched from visual studio</title>
		<link>http://codeblog.shawson.co.uk/iis-express-hanging-when-launched-from-visual-studio/</link>
		<comments>http://codeblog.shawson.co.uk/iis-express-hanging-when-launched-from-visual-studio/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 08:50:41 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[URL Rewriting]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1265</guid>
		<description><![CDATA[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&#8217;t changed any code, got a clean build, but when the browser window opened it just hung, with no error. I eventually [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/' rel='bookmark' title='IIS7 UrlRewrite Outbound links with Compression Enabled'>IIS7 UrlRewrite Outbound links with Compression Enabled</a></li>
<li><a href='http://codeblog.shawson.co.uk/helicon-isapi-rewrite-error-section-isapi_rewrite-not-found/' rel='bookmark' title='Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!'>Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!</a></li>
<li><a href='http://codeblog.shawson.co.uk/machine-key-generator/' rel='bookmark' title='Machine Key Generator'>Machine Key Generator</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>Since checkout I hadn&#8217;t changed any code, got a clean build, but when the browser window opened it just hung, with no error.  </p>
<p>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!</p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/' rel='bookmark' title='IIS7 UrlRewrite Outbound links with Compression Enabled'>IIS7 UrlRewrite Outbound links with Compression Enabled</a></li>
<li><a href='http://codeblog.shawson.co.uk/helicon-isapi-rewrite-error-section-isapi_rewrite-not-found/' rel='bookmark' title='Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!'>Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!</a></li>
<li><a href='http://codeblog.shawson.co.uk/machine-key-generator/' rel='bookmark' title='Machine Key Generator'>Machine Key Generator</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/iis-express-hanging-when-launched-from-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IIS7 UrlRewrite Outbound links with Compression Enabled</title>
		<link>http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/</link>
		<comments>http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 07:50:57 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[URL Rewriting]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1163</guid>
		<description><![CDATA[I&#8217;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; &#60;rewrite&#62; &#60;rules&#62; &#60;rule name=&#34;InboundFriendlyAboutUs&#34; stopProcessing=&#34;true&#34;&#62; &#60;match url=&#34;^about-our-car-finance$&#34; /&#62; &#60;conditions&#62; &#60;add input=&#34;{REQUEST_FILENAME}&#34; matchType=&#34;IsFile&#34; negate=&#34;true&#34; /&#62; &#60;add input=&#34;{REQUEST_FILENAME}&#34; matchType=&#34;IsDirectory&#34; negate=&#34;true&#34; /&#62; &#60;/conditions&#62; &#60;action [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/helicon-isapi-rewrite-error-section-isapi_rewrite-not-found/' rel='bookmark' title='Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!'>Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!</a></li>
<li><a href='http://codeblog.shawson.co.uk/asp-net-aspx-pages-posting-back-to-the-wrong-url-when-using-server-rewrite/' rel='bookmark' title='ASP.net aspx pages posting back to the wrong URL when using Server Rewrite'>ASP.net aspx pages posting back to the wrong URL when using Server Rewrite</a></li>
<li><a href='http://codeblog.shawson.co.uk/iis-express-hanging-when-launched-from-visual-studio/' rel='bookmark' title='IIS Express hanging when launched from visual studio'>IIS Express hanging when launched from visual studio</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started using the <a href="earn.iis.net/page.aspx/657/creating-outbound-rules-for-url-rewrite-" target="_blank">outbound link rewriting feature</a> in the <a href="http://www.iis.net/download/urlrewrite" target="_blank">url rewrite module for IIS7</a>, but initially ran into some problems.</p>
<p>In my web.config, my rewrite section (under system.webServer) looked something like this;</p>
<pre class="brush: xml">
    &lt;rewrite&gt;
      &lt;rules&gt;
        &lt;rule name=&quot;InboundFriendlyAboutUs&quot; stopProcessing=&quot;true&quot;&gt;
          &lt;match url=&quot;^about-our-car-finance$&quot; /&gt;
          &lt;conditions&gt;
            &lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;true&quot; /&gt;
            &lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsDirectory&quot; negate=&quot;true&quot; /&gt;
          &lt;/conditions&gt;
          &lt;action type=&quot;Rewrite&quot; url=&quot;About-Us.aspx&quot; /&gt;
        &lt;/rule&gt;
      &lt;/rules&gt;
      &lt;outboundRules&gt;
        &lt;rule name=&quot;OutboundFriendlyAboutUs&quot; preCondition=&quot;IsHtml&quot;&gt;
          &lt;match filterByTags=&quot;A, Form&quot; pattern=&quot;^(.*)About-Us\.aspx$&quot;/&gt;
          &lt;action type=&quot;Rewrite&quot; value=&quot;{R:1}about-our-car-finance&quot;/&gt;
        &lt;/rule&gt;

        &lt;preConditions&gt;
          &lt;preCondition name=&quot;IsHtml&quot;&gt;
            &lt;add input=&quot;{RESPONSE_CONTENT_TYPE}&quot; pattern=&quot;^text/html&quot;/&gt;
          &lt;/preCondition&gt;
        &lt;/preConditions&gt;
      &lt;/outboundRules&gt;
    &lt;/rewrite&gt;
</pre>
<p>However when I tried to view the page I received a server error;</p>
<blockquote><p>HTTP Error 500.52 &#8211; URL Rewrite Module Error.<br />
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded (&#8220;gzip&#8221;).</p></blockquote>
<p>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&#8217;ll boil it down to a few steps;</p>
<ol>
<li>
On the machine running the web site, from the command line run:<br />
<code>reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v LogRewrittenUrlEnabled /t REG_DWORD /d 0</code><br />
You may need to follow this up with an <code>iisreset</code>
</li>
<li>
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;</p>
<p>&lt;urlCompression doStaticCompression=&#8221;false&#8221; doDynamicCompression=&#8221;true&#8221; dynamicCompressionBeforeCache=&#8221;false&#8221; /&gt;
</li>
<li>
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 &#8220;Modules&#8221; component.  From within here on the right hand side bar, click &#8220;View ordered List&#8230;&#8221; 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.
</li>
</ol>
<p>If you&#8217;re after more details- my source was here; <a href="http://forums.iis.net/t/1165899.aspx" target="_blank">http://forums.iis.net/t/1165899.aspx</a></p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/helicon-isapi-rewrite-error-section-isapi_rewrite-not-found/' rel='bookmark' title='Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!'>Helicon ISAPI Rewrite rules ignored &#8211; You must save the rewrite file with ANSI encoding- NOT UTF8!!</a></li>
<li><a href='http://codeblog.shawson.co.uk/asp-net-aspx-pages-posting-back-to-the-wrong-url-when-using-server-rewrite/' rel='bookmark' title='ASP.net aspx pages posting back to the wrong URL when using Server Rewrite'>ASP.net aspx pages posting back to the wrong URL when using Server Rewrite</a></li>
<li><a href='http://codeblog.shawson.co.uk/iis-express-hanging-when-launched-from-visual-studio/' rel='bookmark' title='IIS Express hanging when launched from visual studio'>IIS Express hanging when launched from visual studio</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.net aspx pages posting back to the wrong URL when using Server Rewrite</title>
		<link>http://codeblog.shawson.co.uk/asp-net-aspx-pages-posting-back-to-the-wrong-url-when-using-server-rewrite/</link>
		<comments>http://codeblog.shawson.co.uk/asp-net-aspx-pages-posting-back-to-the-wrong-url-when-using-server-rewrite/#comments</comments>
		<pubDate>Tue, 04 May 2010 15:38:41 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[URL Rewriting]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=528</guid>
		<description><![CDATA[Had a problem today working on a new phase of one of our existing sites (a problem which I&#8217;m sure I came up against on another site and fixed a few years ago&#8230;) &#8211; we just added server rewrite with a whole new URL structure like so; www.site.com/ group name/ series name/ book.htm This allows [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/creating-a-re-usable-shopping-basket-with-generics-in-c-sharp/' rel='bookmark' title='Creating a re-usable shopping basket with Generics in C#'>Creating a re-usable shopping basket with Generics in C#</a></li>
<li><a href='http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/' rel='bookmark' title='IIS7 UrlRewrite Outbound links with Compression Enabled'>IIS7 UrlRewrite Outbound links with Compression Enabled</a></li>
<li><a href='http://codeblog.shawson.co.uk/syndicating-to-rss-using-the-build-in-net-syndicationfeed-classes/' rel='bookmark' title='Syndicating to RSS using the built in .net SyndicationFeed classes'>Syndicating to RSS using the built in .net SyndicationFeed classes</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Had a problem today working on a new phase of one of our existing sites (a problem which I&#8217;m sure I came up against on another site and fixed a few years ago&#8230;) &#8211; we just added server rewrite with a whole new URL structure like so;</p>
<pre>www.site.com/ group name/ series name/ book.htm</pre>
<p>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 &#8220;Add to cart&#8221; button&#8211; bit of a show stopper.</p>
<p>This was because dot net isn&#8217;t aware of the rewrite- so while they hit the site on a url like;</p>
<pre>childrens-books/beast-quest/book1.htm</pre>
<p>asp.net thought the page was at</p>
<pre>book-details.aspx?id=9780123456789&amp;catId=1&amp;seriesId=2</pre>
<p>so did a post back to that page, relative to the current folder, giving me;</p>
<pre>childrens-books/beast-quest/book-details.aspx?id=9780123456789&amp;catId=1&amp;seriesId=2</pre>
<p>trying to reference the physical file (which existed at the root level) from the context of a folder which doesn&#8217;t really exist.  The fix is easy (once you find it!) &#8211; for this site the main asp.net form tag was in the masterpage so I just added the following to the Page_Load of my master page;</p>
<p>form1.Action = Request.RawUrl;</p>
<p>Thanks to <a href="http://learn.iis.net/page.aspx/517/url-rewriting-for-aspnet-web-forms/" target="_blank">Ruslan Yakushev&#8217;s post on IIS.net</a></p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/creating-a-re-usable-shopping-basket-with-generics-in-c-sharp/' rel='bookmark' title='Creating a re-usable shopping basket with Generics in C#'>Creating a re-usable shopping basket with Generics in C#</a></li>
<li><a href='http://codeblog.shawson.co.uk/iis7-urlrewrite-outbound-links-with-compression-enabled/' rel='bookmark' title='IIS7 UrlRewrite Outbound links with Compression Enabled'>IIS7 UrlRewrite Outbound links with Compression Enabled</a></li>
<li><a href='http://codeblog.shawson.co.uk/syndicating-to-rss-using-the-build-in-net-syndicationfeed-classes/' rel='bookmark' title='Syndicating to RSS using the built in .net SyndicationFeed classes'>Syndicating to RSS using the built in .net SyndicationFeed classes</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/asp-net-aspx-pages-posting-back-to-the-wrong-url-when-using-server-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

