MVC 5 인터넷 응용 프로그램을 개발 중이며 Identity 2.1
을 사용 중입니다.MVC 5 - 사용자에게 소유권 주장 추가
사용자가 로그인 한 후 claim
을 추가 할 수있는 곳, 내가 username
을 알고 있습니까? 여기
내가 무엇을 가지고 :
public void AddClaimToUser(string userName, string type, string value)
{
var AuthenticationManager = HttpContext.Current.GetOwinContext().Authentication;
var Identity = new ClaimsIdentity(userName);
Identity.AddClaim(new Claim(type, value));
AuthenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(Identity), new AuthenticationProperties { IsPersistent = true });
}
그러나, 나는이 메소드를 호출, 나는 사용자의 주장을 확인 후, 추가 claim
가 표시되지 않습니다. 사전에
var identity = (ClaimsIdentity)User.Identity;
IEnumerable<Claim> claims = identity.Claims;
감사 : 여기
내가 컨트롤러의 주장을 얻기 위해 사용하고있는 코드입니다.