简体   繁体   中英

MVC login action not redirecting after form authenticated

I have below controller login action.

在此处输入图片说明

Once everything done, Redirect(returnUrl) is not redirecting to " http://localhost:53821/Reviews/New " page. It is sitting in the same page.

[AllowAnonymous]
public ActionResult Login() {
  return this.View();
}

[HttpPost]
[AllowAnonymous]
public ActionResult Login(RH.ViewModel.LogOnVM logOn, string returnUrl) {
  if (ModelState.IsValid) {
    FormsAuthentication.SetAuthCookie(logOn.Username, false);
    return this.Redirect(returnUrl);
  }

  return this.View(logOn);
}

Once it went through [HttpPost] Login, again it is hitting [HttpGet] login and same login view is getting displayed.

Did you have [Authorize] in any controller?

[Authorize]

If the user is not authenticated, this [Authorize] will redirect you to the login page again, continuously.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM