首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >c# Identity LogOff和打印消息

c# Identity LogOff和打印消息
EN

Stack Overflow用户
提问于 2015-08-06 18:14:00
回答 1查看 129关注 0票数 0

在我的CookieAuthenticationExpireTimeSpan中定义了一段时间后,我的用户正确注销,我想在注销发生时在我的登录重定向中打印一条消息,有什么方法可以做到这一点吗?

代码语言:javascript
运行
复制
 app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            ExpireTimeSpan = TimeSpan.FromMinutes(30),
            SlidingExpiration = true,
            LoginPath = new PathString("/signin"),
            CookieName = ".Cookies",
            Provider = new CookieAuthenticationProvider
            {
                // Enables the application to validate the security stamp when the user logs in.
                // This is a security feature which is used when you change a password or add an external login to your account.  
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    validateInterval: TimeSpan.FromMinutes(30),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
            }
        });
EN

回答 1

Stack Overflow用户

发布于 2015-08-06 18:22:41

您可以指定自定义重定向,如下所示:

代码语言:javascript
运行
复制
    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            // [...]
            Provider = new CookieAuthenticationProvider
            {
                // [...]
                OnApplyRedirect = ApplyRedirect
            }
        });

        app.Use<ClaimsLogger>();
    }

    private static void ApplyRedirect(CookieApplyRedirectContext context)
    {
        // custom redirect logic
        var uri = context.RedirectUri;
        context.Response.Redirect(uri);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31853029

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档