0

我使用 .NET MVC 制作了一个应用程序,但有一个似乎无法解决的错误。

当我启动我的应用程序并且您仍然从上次登录时开始您似乎已登录,但是当您单击页面时可以说“管理仪表板”(需要您登录)它会一直加载并且它因超时错误而关闭。

如果我注销并重新登录,它工作得很好。

我怎样才能使它在您启动应用程序时始终退出?:)

提前致谢。

使用 .NET 实体框架 5.0.0

编辑:我尝试过 persistcookie: false 但这没有用。重新启动 mvc 应用程序后我仍然登录。我的登录操作代码在 accountcontroller 中:

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Login(LoginModel model, string returnUrl)
    {
        if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
        {
            if (returnUrl == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                return Redirect(Server.UrlDecode(returnUrl));
            }

        }

        // If we got this far, something failed, redisplay form
        ModelState.AddModelError("", "The user name or password provided is incorrect.");
        return View(model);
    }
4

1 回答 1

1

你打电话时

WebSecurity.Login

方法集persistCookie = false

尽管您不必这样做..但是没有实际代码,我只能回答您的问题。

于 2014-10-28T00:08:24.800 回答