首页 > 解决方案 > 跨子域和 SecurityStampValidatorOptions 的 ASP.NET Core 3.1 身份 cookie

问题描述

有人帮我解决这个问题吗?

我有

services.AddIdentity<User, IdentityRole>(...)

接着

services.ConfigureApplicationCookie(options =>
            {
                options.Cookie.Name = "somename";
                options.Cookie.Domain = ".somename"

                options.Events = new CookieAuthenticationEvents()
                {
                    OnRedirectToLogin = (context) =>
                    {               
                        context.HttpContext.Response.Redirect("somesite/login/));
                        return Task.CompletedTask;
                    },
                };
                options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
            });

最后:

services.Configure<SecurityStampValidatorOptions>(options =>
            {
                options.ValidationInterval = TimeSpan.FromSeconds(10);
            });

授权完美地在所有域上进行。但是最后一项服务无法正常工作。例如,当我更新用户角色时。您需要注销并重新登录。

如何解决这个问题?谢谢。

标签: asp.net-coreidentity

解决方案


推荐阅读