Asp.net mvc 5 ASP.NET身份用户在30分钟后注销

Asp.net mvc 5 ASP.NET身份用户在30分钟后注销,asp.net-mvc-5,asp.net-identity,Asp.net Mvc 5,Asp.net Identity,我正在开发一个应用程序,但30分钟后我就会注销,即使我在过去30分钟内一直处于活动状态 这在ConfigureAuth方法中: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"),

我正在开发一个应用程序,但30分钟后我就会注销,即使我在过去30分钟内一直处于活动状态

这在ConfigureAuth方法中:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User, string>(
        validateInterval: TimeSpan.FromMinutes(30),
        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
        getUserIdCallback:(id) => id.GetUserId())
    }
}
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/Login”),
Provider=新CookieAuthenticationProvider
{
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromMinutes(30),
regenerateIdentityCallback:(管理器,用户)=>user.GenerateUserIdentityAsync(管理器),
getUserIdCallback:(id)=>id.GetUserId()
}
}

我正在本地主机上的IIS Express中测试该应用程序。

SlidingExpiration=true
添加到正在设置的属性列表中

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User, string>(
        validateInterval: TimeSpan.FromMinutes(30),
        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
        getUserIdCallback:(id) => id.GetUserId())
    },
    // Add this
    SlidingExpiration = true,
    //Use this to customize the timeout duration if the default is too short/long
    ExpireTimeSpan = TimeSpan.FromMinutes(30) 
}
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/Login”),
Provider=新CookieAuthenticationProvider
{
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromMinutes(30),
regenerateIdentityCallback:(管理器,用户)=>user.GenerateUserIdentityAsync(管理器),
getUserIdCallback:(id)=>id.GetUserId()
},
//加上这个
slidengexpiration=true,
//如果默认值太短/太长,则使用此选项自定义超时持续时间
ExpireTimeSpan=时间跨度从分钟(30)
}

SlidingExpiration=true
添加到正在设置的属性列表中

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User, string>(
        validateInterval: TimeSpan.FromMinutes(30),
        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
        getUserIdCallback:(id) => id.GetUserId())
    },
    // Add this
    SlidingExpiration = true,
    //Use this to customize the timeout duration if the default is too short/long
    ExpireTimeSpan = TimeSpan.FromMinutes(30) 
}
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/Login”),
Provider=新CookieAuthenticationProvider
{
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromMinutes(30),
regenerateIdentityCallback:(管理器,用户)=>user.GenerateUserIdentityAsync(管理器),
getUserIdCallback:(id)=>id.GetUserId()
},
//加上这个
slidengexpiration=true,
//如果默认值太短/太长,则使用此选项自定义超时持续时间
ExpireTimeSpan=时间跨度从分钟(30)
}

它是否与会话超时有关。我认为默认超时是20分钟,您将因此注销。它是否与会话超时有关。我认为默认超时是20分钟,您将因此注销。这两行“regenerateIdentityCallback:(经理、用户)的含义是什么=>user.GenerateUserIdentityAsync(manager),getUserIdCallback:(id)=>id.GetUserId())`这两行的意思是什么` regenerateIdentityCallback:(manager,user)=>user.GenerateUserIdentityAsync(manager),getUserIdCallback:(id)=>id.GetUserId())`