我正在使用 BrockAllen.MembershipReboot
与索赔的确切更新时间有关的索赔处理存在问题。下面的代码应该证明我的问题......
private function UpdateGender(string newGender)
{
account.RemoveClaim(ClaimTypes.Gender);
account.AddClaim(ClaimTypes.Gender, newGender);
userAccountService.Update(account);
// since we've changed the claims, we need to re-issue the cookie that
// contains the claims.
authSvc.SignIn(User.Identity.Name);
}
[HttpPost]
public JsonResult function myAjaxMethod(){
UpdateGender("male");
string gender = System.Security.Claims.ClaimsPrincipal.Current.Claims.GetValue(ClaimTypes.Gender);
// the "gender" variable will never be "male" in this request (unless it was already male)
// because although we've set the cookie it hasn't updated the claim until the next request
// when it reads the cookie again.
return Json(gender);
}
我的问题是这样的:
有没有办法强制该System.Security.Claims.ClaimsPrincipal.Current.Claims.GetValue()
方法在发出 cookie 时更新它的声明?