AspNet身份-如何在60分钟不活动时强制注销用户时记录用户信息

时间:2018-10-06 12:46:06

标签: asp.net asp.net-identity

我有一项服务,可以在用户手动单击注销页面时记录用户信息。

我正在使用AspNet Identity 2.0,并且我将60分钟的ExpireTimeSpan设置为SlidingExpiration为true。

当用户点击退出页面时,我该如何调用服务来记录用户信息。

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/account/login"),

    Provider = new CookieAuthenticationProvider
    {
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager<User>, User>(
            validateInterval: TimeSpan.FromMinutes(30),
            regenerateIdentity: (manager, user) => manager.GenerateUserIdentityAsync(user))
    },

    //This will force user to re-login if inactive for x minutes.
    SlidingExpiration = true,
    ExpireTimeSpan = TimeSpan.FromMinutes(loginTimeout)

});

谢谢。

0 个答案:

没有答案