title: Redirect(relativeUrl) redirecting to wrong path in IIS
body: <p>In the usual <code>AccountController</code> in my MVC3 app, if <code>returnUrl</code> is set (in my case, I set it manually), it will call <code>Redirect(returnUrl)</code>.</p>
  
  <p>Assume my return URL is <code>/Admin/HealthCheck</code> (which it really is). When I'm debugging, I get a URL like <code>http://localhost:3279/Admin/HealthCheck</code> from the redirect call.</p>
  
  <p>Then, I deployed my app to <code>http://localhost/Test</code>. In this case, <code>Redirect(returnUrl)</code> redirects me to <code>http://localhost/Admin/HealthCheck</code> and <em>not</em> the expected <code>http://localhost/Test/Admin/HealthCheck</code>.</p>
  
  <p>What's going on here? How do I fix this (if it is fixable)?</p>
  
  <p>Below is a snippet from the (standard) MVC3 AccountController; you can see where I get the return URL from the query string (eg. <code>http://localhost/Test/LogOn?ReturnUrl=/Admin/HealthCheck</code>, albeit URL encoded).</p>
  
  <pre><code>[HttpPost]
          public ActionResult LogOn(LogOnModel model, string returnUrl)
          {
              if (ModelState.IsValid)
              {
                  if (Membership.ValidateUser(model.UserName, model.Password))
                  {
                      returnUrl = Request.Params["ReturnUrl"];
  
                      FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                      if (Url.IsLocalUrl(returnUrl) &amp;&amp; returnUrl.Length &gt; 1 &amp;&amp; returnUrl.StartsWith("/")
                          &amp;&amp; !returnUrl.StartsWith("//") &amp;&amp; !returnUrl.StartsWith("/\\"))
                      {
                          return Redirect(returnUrl);
                      }
                      else
                      {
                          return RedirectToAction("Index", "Home");
                      }
                  }
                  else
                  {
                      ModelState.AddModelError("", "The user name or password provided is incorrect.");
                  }
              }
  </code></pre>