设置子域的登录cookie

时间:2014-03-04 16:43:40

标签: asp.net asp.net-mvc authentication routing asp.net-mvc-5

我有一个带有用户帐户的MVC 5 Web应用程序。

每个帐户都有自己的子域名(http://accountname.myapp.com

我希望有一个用户可以登录的中央登录页面。

第一个与accountname完美配合。但是我怎样才能实现第二个呢?

当我在http://myapp.com/Login登录然后重定向用户时,是否有可能将身份验证Cookie设置为accountname.myapp.com?

我的登录方法目前看起来像这样:

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);

0 个答案:

没有答案