Request.Url is URL encoded twice
<p>I got a problem where my URL is URL encoded twice. We have a feature where we detect if the page the visitor visits require SSL or not. If it does, we redirect to the same URL but with HTTPS instead of HTTP and vice verse. The problem we have is when we redirect from HTTPS to HTTP on an URL with special characters (czech characters)</p>

<p>I'll show by example and maybe someone can explain what's going on.</p>

<ol>
<li>I'm on a page with https://</li>
<li>I click a link with the href: "/cz/ženy/již-brzy-v-prodeji/" (/cz/%C5%BEeny/ji%C5%BE-brzy-v-prodeji/ URL encoded)</li>
<li>In fiddler I get a 302:

<ul>
<li>GET
/cz/%C5%BEeny/ji%C5%BE-brzy-v-prodeji/ HTTP/1.1 </li>
<li>Location: <a href="http://.../cz/%25C5%25BEeny/ji%25C5%25BE-brzy-v-prodeji/" rel="nofollow">http://.../cz/%25C5%25BEeny/ji%25C5%25BE-brzy-v-prodeji/</a></li>
</ul></li>
<li>The resulting URL becomes: <a href="http://.../cz/%25C5%25BEeny/ji%25C5%25BE-brzy-v-prodeji/" rel="nofollow">http://.../cz/%25C5%25BEeny/ji%25C5%25BE-brzy-v-prodeji/</a></li>
<li>The resulting URL gives a 404</li>
</ol>

<p>As you can see, the resulting URL is twice URL encoded. The code we're using for this action starts with</p>

<pre><code>string newUrl = Request.Url.AbsoluteUri.Replace("https://", "http://");
</code></pre>

<p>Debugging this newUrl is already URL encoded twice as seen in step 3 above.</p>

<p>If I look at Request.RawUrl it is not URL encoded at all. Any idea what's going wrong? Perhaps I must use RawUrl instead and construct the protocol etc. myself?</p>

<p>Further testing has been done, and I don't think the SSL has anything to do with it at all. On a normal page when i check Request.Url.AbsolutPath it's also encoded twice.</p>