title: What is the correct method to redirect to the returnurl after logging in to an MVC ASP.Net application?
body: <p>Here is my login controller</p>
  
  <pre><code>        // POST: /Account/Login
  
      [AllowAnonymous]
      [HttpPost]
  
      public ActionResult Login(LoginModel model, string ReturnUrl)
      {
          if (ModelState.IsValid)
          {
              if (Membership.ValidateUser(model.UserName, model.Password))
              {
                  FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                  if (Url.IsLocalUrl(ReturnUrl))
                  {
                      return RedirectToAction("Index", "Home");
                  }
                  else
                  {
                      return RedirectToAction("Login", "Login");
                  }
              }
              else
              {
                  ModelState.AddModelError("invalid", "The user name or password provided is incorrect.");
  
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>When I start debugging this is the url on the login page:</p>
  
  <pre><code>http://localhost:8085/MobileApprover/Login/Login?ReturnUrl=%2fMobileApprover%2f&amp;AspxAutoDetectCookieSupport=1 
  </code></pre>
  
  <p>and this is the form I am using to post </p>
  
  <pre><code>&lt;form class="form" action="/MobileApprover/Login/Login?ReturnUrl=&lt;%=Request.QueryString["ReturnUrl"]%&gt;" method="post"&gt;
  
  &lt;input type="text" class="span12" name="UserName" placeholder="User Name" /&gt;
  &lt;input type="password" class="span12" name="Password" class="" placeholder="Password"/&gt;
  
  &lt;label class="checkbox"&gt; 
      &lt;input type="checkbox" name="RememberMe" class="" /&gt; 
  Remember Me? 
  &lt;/label&gt;                   
  &lt;button type="submit""&gt;Login&lt;/button&gt;        
         &lt;%:
            Html.ValidationSummary()   
         %&gt; 
  </code></pre>
  
  <p></p>
  
  <p>After logging in I am at this url: </p>
  
  <pre><code> http://localhost:8085/MobileApprover/Login/Login?ReturnUrl=%2fMobileApprover%2f&amp;AspxAutoDetectCookieSupport=1#/MobileApprover/Login/Login?ReturnUrl=/MobileApprover/
  </code></pre>
  
  <p>I would like to be at this url http:localhost:8085/MobileApprover because when I type in that url (when debugging) the home controller correctly displays the view. </p>
  
  <p>What am I doing wrong at this point? I believe the issue is related to the return url and how I am handling it but I have tried to </p>
  
  <pre><code>return Redirect(ReturnURL) 
  </code></pre>
  
  <p>but that does not work either.</p>