Skip to content

Instantly share code, notes, and snippets.

@rionmonster
Created January 5, 2016 16:59
Show Gist options
  • Save rionmonster/f263dde9f814d079da92 to your computer and use it in GitHub Desktop.
Save rionmonster/f263dde9f814d079da92 to your computer and use it in GitHub Desktop.
RedirectToAction throwing 503.2 "Bad Gateway Error"
[HttpPost]
[Route("Account/LogIn")]
public async Task<IActionResult> LogIn(SignInViewModel model, string returnUrl = null)
{
// If you put the redirect here, it works fine...
ViewData["ReturnUrl"] = returnUrl;
if (ModelState.IsValid)
{
// This doesn't count login failures towards account lockout
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, true, false);
if (result.Succeeded)
{
if (Url.IsLocalUrl(returnUrl))
{
return RedirectToLocal(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("Generic", "Invalid login attempt.");
return View(model);
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment