Single Sign On is not working in Chrome Browser using ASP.NET Identity RRS feed

  • Question

  • User611346789 posted


    I have developed single sign on using Forms Authentication at very beginning of our software but then i have changed authentication system to ASP.NET Identity and remove Forms Authentications. That's why I need to configure SSO again and i have done that using The below Code

    In Startup.Auth.cs file

    app.UseCookieAuthentication(new CookieAuthenticationOptions
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                    LoginPath = new PathString("/Home/Login"),
                    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.FromDays(30),
                            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                    ExpireTimeSpan = TimeSpan.FromDays(30),
                    CookieName = "cookieName",
                    CookieDomain = ".localhost"
                AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

    Then when user login then i am settings the cookie using below code :

    At the time of Login

    var claims = new List<Claim>();
                claims.Add(new Claim(ClaimTypes.NameIdentifier, userDetails.Id));
                claims.Add(new Claim(ClaimTypes.Name, userDetails.UserName));
                var identity = new ClaimsIdentity(claims,DefaultAuthenticationTypes.ApplicationCookie);
                AuthenticationManager.SignIn(new AuthenticationProperties()
                    AllowRefresh = true,
                    IsPersistent = isPersistent,
                    ExpiresUtc = Core.GetServerDatetime().AddMinutes(35000),
                    IssuedUtc = Core.GetServerDatetime()

    Above code is in my Project A

    I have also write same configuration in another project named Project B

    In Startp.cs

    app.UseCookieAuthentication(new CookieAuthenticationOptions ()
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                    ExpireTimeSpan = TimeSpan.FromDays(30),
                    LoginPath = new PathString("/Unauthorized/Index"),
                    CookieName = "cookieName",
                    CookieDomain = ".localhost",
                    SlidingExpiration = true
                AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

    The complete configuration is working in only Mozilla Browser but not working in Chrome and Edge browser. I have also set same machine key, Decryption key  in both project web.config file and also both project Identity version is same.

    Can you please help me to solve this problem.

    ** One Important thing that in chrome browser i can not Login from main project. When trying to login authorization successful but that's redirect to again in login page everytime. In debug Mode I have checked that HttpContext.Current.User.Identity.IsAuthenticated become tru in Mozilla but not in Chrome

    Thanks in advance

    Sunday, November 18, 2018 5:06 AM

All replies

  • User1724605321 posted

    Hi Emrul Kayes,

    Do the both applications are published to HTTPS enabled websites ? 

    Best Regards,

    Nan Yu

    Monday, November 19, 2018 2:42 AM