验证会话超时

Old*_*zer 5 asp.net-mvc asp.net-identity

我正在使用VS2013 .NET Framework 4.5.1中的MVC模板提供的内置Identity框架.

我或多或少地开箱即用.它一直很好.与我读过的其他帖子相比,我的web.config有:

<authentication mode="None" />
Run Code Online (Sandbox Code Playgroud)

如何为经过身份验证的会话设置超时时间,即用户登录后?

And*_*ena 9

如果您使用Owin身份验证,StartUp.csApp_Start文件夹中的文件应该包含以下内容:

public void ConfigureAuth(IAppBuilder app)
{
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login"),
        // here you go
        ExpireTimeSpan = new TimeSpan(60000000000)
    });
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
}
Run Code Online (Sandbox Code Playgroud)