It looks like claims are way to go with ASP.NET Core (3.1) authorization, but my question is how can we have integer values not only strings? I want to store some IDs in the claims:
var userid = 123; // try "123"
var claimsIdentity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
claimsIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userid, ClaimValueTypes.Integer32));
Or any better way to do it? TIA
The claims can only be represented as strings. So you can convert userid to string , and on other side decode token , get claim and convert to int again if needed .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.