Home > Software design >  Redirect To Action Not Working Based On Provided Path
Redirect To Action Not Working Based On Provided Path

Time:09-16

Currently the page redirect is not working. The page URL is at http://localhost:40823/Account/SignIn. The page is not redirecting at all. I have no idea why this method is not rerouting. Any ideas? I set a breakpoint and walked through my code it reaches the return statement but it does not work. I have used this else where and it works perfectly fine. I just copied over the return statement here but it does not work.

    [HttpPost]
    public ActionResult PasswordRequest(string email)
    {
        Player player= GetPlayer();

        try
        {
            player.Email = Login.EmailAddress = email;
            ResetPassword(player);
        }
        catch(Exception ex) {
             console.log("Error")
        }

        return RedirectToAction("SignIn", "Account");
    }

CodePudding user response:

You are using ajax to call the PasswordRequest action, ajax ignores all redirects and always returns to success: or to error javascript function. You will have to use submit button or ancor tag to call PasswordRequest if you want to use redirect inside of the controller. Another way is to assign window.location.href =http://localhost:40823/Account/SignIn inside of success ajax function.

  • Related