title: ASP.Net Core MVC RedirectToAction is appending controller name in front of returnUrl
body: <p>I am working on a ASP.Net core, MVC 6 application. I have an AppControler as my initial controller and if a user tries to go to an action that has an [Authorize] attribute, I redirect to my AuthController for the login, passing in the returnUrl for the return. Once authenticated, I use ... return RedirectToAction(returnUrl). </p>
  
  <p>In debug, I can see that the returnUrl string is set to /App/Timesheets. However, in the browser address bar, it has an address of <a href="http://localhost:49940/Auth/%2FApp%2FTimeSheets" rel="nofollow noreferrer">http://localhost:49940/Auth/%2FApp%2FTimeSheets</a>. For some reason it is appending the controller name (Auth) in front of the returnUrl.</p>
  
  <p>Here is my Login action in the AuthController</p>
  
  <pre><code>    [HttpPost]
      public async Task&lt;ActionResult&gt; Login(LoginViewModel vm, string returnUrl)
      {
          if (ModelState.IsValid)
          {
              var signInResult = await _signInManager.PasswordSignInAsync(vm.Username, vm.Password, true, false);
  
              if (signInResult.Succeeded)
              {
                  if (string.IsNullOrWhiteSpace(returnUrl))
                  {
                      return RedirectToAction("Timesheets", "App");
                  }
                  else
                  {
                      return RedirectToAction(returnUrl);
                  }
              }
              else
              {
                  ModelState.AddModelError("", "Username or password incorrect");
              }
          }
  
          return View();
      }
  </code></pre>
  
  <p>I can manually enter <a href="http://localhost:49940/App/Timesheets" rel="nofollow noreferrer">http://localhost:49940/App/Timesheets</a> in the browser address bar and get to the correct view. Also, if I add</p>
  
  <pre><code>returnUrl = String.Empty;  //Test Only
  </code></pre>
  
  <p>before the line...</p>
  
  <pre><code>if (string.IsNullOrWhiteSpace(returnUrl))
  </code></pre>
  
  <p>to cause it to execute the line...</p>
  
  <pre><code>return RedirectToAction("Timesheets", "App");
  </code></pre>
  
  <p>The redirection works just fine. So it has something to do with passing in a string variable in the <code>"/Controller/Action"</code> format that is the problem.</p>
  
  <p>Any ideas?</p>