1

私は 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 が発行された時点でクレームを強制的に更新する方法はありますか?

4

1 に答える 1