title: Using Url.Content from within a WebForms page incorrectly resolves the tilde
body: <p>So a long long time ago we added MVC 1.0 to an existing ASP.NET 2.0 WebForms site and during that upgrade we made MVC's UrlHelper available to our existing WebForms code. This meant that within our WebForms code we could do such things as:</p>
  
  <pre><code>&lt;%= Url.Content("~/this/is/nice") %&gt;
  </code></pre>
  
  <p>to output the Url</p>
  
  <pre><code>mysite.com/this/is/nice
  </code></pre>
  
  <p>which was nice and worked great.</p>
  
  <p>Fast forward to more recent times and we're looking to move our application to a new home (new servers) and the above functionality is now misbehaving, now:</p>
  
  <pre><code>&lt;%= Url.Content("~/this/is/nice") %&gt;
  </code></pre>
  
  <p>now outputs</p>
  
  <pre><code>mysite.com/webforms/location/this/is/nice
  </code></pre>
  
  <p>as if the physical location is the application root - and I've no idea why and have been unsuccessful in recreating it on my development machine.</p>
  
  <p>Does anyone out there what can possibly be the cause of this? I've been stuck on this problem for the past few days now and am nearly out of ideas. The only glimmer of hope I have right now is that the problem occurs on my colleague's environment so it's definitely an issue we can recreate.</p>
  
  <p>Update: it doesn't happen on all WebForms pages - just certain ones and the only differing characteristic I've noticed so far is that it's occurring on a page where some Url rewriting is going on.</p>