简体   繁体   English

表单身份验证后,MVC登录操作未重定向

[英]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. 完成所有操作后, Redirect(returnUrl)不会重定向到“ http:// localhost:53821 / Reviews / New ”页面。 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. 通过[HttpPost]登录后,再次点击[HttpGet]登录,并显示相同的登录视图。

Did you have [Authorize] in any controller? 您在任何控制器中都具有[Authorize]吗?

[Authorize]

If the user is not authenticated, this [Authorize] will redirect you to the login page again, continuously. 如果用户未通过身份验证,则此[Authorize]将连续不断地将您重定向到登录页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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