I have a MVC 5 web application with user accounts.
Each account gets it's own subdomain (http://accountname.myapp.com)
I want to have a central login-page where users can login.
- They should be able to login at http://accountname.myapp.com/Login and
- They should be able to login at http://myapp.com/login and get redirected to http://accountname.myapp.com
The first with accountname works perfectly. But how can I achieve the second one?
Is there a possibilty to set the Authentication Cookie to accountname.myapp.com when I login at http://myapp.com/Login and then redirect the user?
My login method looks like this at the moment:
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Sid, authUser.Id.ToString()));
claims.Add(new Claim(ClaimTypes.PrimarySid, authUser.Account.Id.ToString()));
claims.Add(new Claim(ClaimTypes.Email, authUser.Email));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
//AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = model.Remember }, identity);