我有一个使用System.Security.Claims的应用程序,在用户登录后说www.mysite.co.uk,然后将网址更改为mysite.co.uk,他们就会被注销。
如何阻止他们退出并在两个网址之间保持登录?
这是用户在经过身份验证后记录的当前代码:
var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Email, user.Email) }, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Email, ClaimTypes.Role);
identity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", user.Id.ToString()));
identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", user.Id.ToString()));
identity.AddClaim(new Claim("UserId", user.Id.ToString()));
identity.AddClaim(new Claim("ProfileImageUrl", user.ProfileImageUrl));
identity.AddClaim(new Claim("FirstName", user.FirstName));
identity.AddClaim(new Claim("SecondName", user.SecondName));
Int32 unixTimestamp = (Int32)(user.SignUpDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
identity.AddClaim(new Claim("SignUpDate", unixTimestamp.ToString()));
identity.AddClaim(new Claim("Name", user.FullName));
identity.AddClaim(new Claim("Username", user.Username));
identity.AddClaim(new Claim("Email", user.Email));
identity.AddClaim(new Claim("Role", user.Role));
identity.AddClaim(new Claim("Verified", user.Verified.ToString()));
identity.AddClaim(new Claim("VerifiedString", user.Verified ? "Verified" : "Unverified"));
if (this.Authentication == null)
{
return this.View("Login");
}
var persist = remember == null ? false : remember.Value;
this.Authentication.SignIn(new AuthenticationProperties { IsPersistent = persist }, identity);
答案 0 :(得分:0)
如果你使用auth cookie,那就有你的问题:cookie域。您可以为mysite.co.uk发布另一个cookie。