Created
January 5, 2016 16:59
-
-
Save rionmonster/f263dde9f814d079da92 to your computer and use it in GitHub Desktop.
RedirectToAction throwing 503.2 "Bad Gateway Error"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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