加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – SignInManager.PasswordSignInAsync对我说谎

发布时间:2020-12-16 04:23:54 所属栏目:asp.Net 来源:网络整理
导读:我一直在使用此代码登录: //// GET: /Account/Login[AllowAnonymous]public ActionResult Login(string returnUrl){ ViewBag.ReturnUrl = returnUrl; return View();}//// POST: /Account/Login[HttpPost][AllowAnonymous][ValidateAntiForgeryToken]public
我一直在使用此代码登录:
//
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
    ViewBag.ReturnUrl = returnUrl;
    return View();
}

//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model,string returnUrl)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }

    // This doesn't count login failures towards account lockout
    // To enable password failures to trigger account lockout,change to shouldLockout: true
    var result = await SignInManager.PasswordSignInAsync(model.Email,model.Password,model.RememberMe,shouldLockout: false);
    switch (result)
    {
        case SignInStatus.Success:
            return RedirectToLocal(returnUrl);
        case SignInStatus.LockedOut:
            return View("Lockout");
        case SignInStatus.RequiresVerification:
            return RedirectToAction("SendCode",new { ReturnUrl = returnUrl,RememberMe = model.RememberMe });
        case SignInStatus.Failure:
        default:
            ModelState.AddModelError("",Account.LoginFailure);
            return View(model);
    }
}

这是Visual Studio MVC应用程序模板附带的代码.它一直工作到一天突然停止工作.我已通过此代码调试SignInManager.PasswordSignInAsync返回成功,但在以下请求中,我尚未登录.

更新:

我搁置了所有挂起的更改,但仍然无法登录.我是唯一一个处理此代码的人.这不是我在做什么.

进一步更新:

此代码适用于我的同事机器.当我将它发布到登台服务器时,它可以工作.它只是无法在我的电脑上工作.

解决方法



The page is not found

nginx error!

The page you are looking for is not found.

Website Administrator

Something has triggered missing webpage on your
website. This is the default 404 error page for
nginx that is distributed with
Fedora. It is located
/usr/share/nginx/html/404.html

You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读