跨子域共享ASP.Net MVC身份cookie

时间:2019-03-25 07:21:13

标签: asp.net-mvc cookies subdomain

我在多个子域中托管了一个应用程序,如
1- www.mydomain.ae
2- student.mydomain.ae
3- teacher.mydomain.ae

Startup.Auth.cs文件中,我添加了以下行

app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
     LoginPath = new PathString("/en/Account/Login"),

     CookieDomain = ".mydomain.ae",  /****ADDED THIS LINE***/

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

当我按下CTRL+F5时,它可以在我的本地环境中运行,但是在实时服务器上发布并上传后,它不起作用

编辑:其他内容
我还注意到注销已重定向到主页,但未清除cookie。登录后无法注销

0 个答案:

没有答案