当会话过期时,如何重定向到登录页面.asp.net MVC 5.asp.net Identity 2.0



我在VS2013中使用最新的ASP.net Identity 2.0创建了默认的web项目。我想知道需要什么设置来改变日志会话的超时,以便我可以实际测试。

你可以在Startup.Auth.cs中重写这个

        // Enable the application to use a cookie to store information for the signed in user
        // and to use a cookie to temporarily store information about a user logging in with a third party login provider
        // Configure the sign in cookie
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            Provider = new CookieAuthenticationProvider
            {
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    validateInterval: TimeSpan.FromMinutes(1),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
            },
            //*** This will override the default **** 
            ExpireTimeSpan = TimeSpan.FromMinutes(1)
        });

相关内容

  • 没有找到相关文章

最新更新