如何在cookie时间到期后重定向到登录c#owin?

时间:2018-04-17 17:18:34

标签: c# owin identity

我希望你很好,我的代码如下:

                    app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
             AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Login"),
            LogoutPath = new PathString("/Login"),                
            Provider = new CookieAuthenticationProvider
            {
                OnResponseSignIn = context =>
                {
                    context.Properties.AllowRefresh = true; context.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(1);
                },
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    validateInterval: TimeSpan.FromMinutes(1),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)
                    )
            },
            SlidingExpiration = true,
            ExpireTimeSpan = TimeSpan.FromMinutes(1)                 
        });

使用previos代码,应用程序不会重定向到登录。非常感谢。

0 个答案:

没有答案