Asp.net mvc 5 .net MVC标识在会话之间保持不变

Asp.net mvc 5 .net MVC标识在会话之间保持不变,asp.net-mvc-5,identity,Asp.net Mvc 5,Identity,设置我的第一个.NETMVC5项目,登录工作正常,但我注意到,如果我不手动注销,即使一夜之间,身份仍然存在。我原以为isPersistent标志设置为false可以防止出现这种情况,但事实并非如此,我也没有找到任何文档告诉我如何解决这个问题 这是我的异步登录方法 private async Task SignInAsync(SdIdentityUser user, bool isPersistent) { AuthenticationManager.SignOut(DefaultAuth

设置我的第一个.NETMVC5项目,登录工作正常,但我注意到,如果我不手动注销,即使一夜之间,身份仍然存在。我原以为isPersistent标志设置为false可以防止出现这种情况,但事实并非如此,我也没有找到任何文档告诉我如何解决这个问题

这是我的异步登录方法

private async Task SignInAsync(SdIdentityUser user, bool isPersistent)
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
    var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
    Session["user"] = user;
    AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
下面是对该方法的调用

await SignInAsync(user, isPersistent: false);
这是我的Startup.Auth配置

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login")
    });
    // Use a cookie to temporarily store information about a user logging in with a third party login provider
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

如果可能的话,我会删除这个问题。答案是,当正确设置为false时,isPersistent可以正常工作。我的代码有一个缺陷,导致标志被设置为true