2

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.

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);
MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
AxSc
  • 594
  • 1
  • 9
  • 21
  • http://stackoverflow.com/questions/273732/how-can-i-share-a-session-across-multiple-subdomains-in-asp-net – DmitryK Mar 04 '14 at 16:46
  • Hi DmitryK, I'm not getting how the answer to the question in your link can help me. I'm not trying to share sessions - I just want to login users to a subdomain. – AxSc Mar 04 '14 at 16:49

0 Answers0