asp.net mvc - Why does the role claim have incorrect type? -
i downloaded webapp-roleclaims-dotnet sample application , somehow cannot work.
the page has following rather straightforward piece of code:
claimsidentity claimsid = claimsprincipal.current.identity claimsidentity; var approles = new list<string>(); foreach (claim claim in claimsprincipal.current.findall(claimsid.roleclaimtype)) approles.add(claim.value); viewdata["approles"] = approles; return view();
now, expression claimsprincipal.current.findall(claimsid.roleclaimtype)
returns empty list, though have proper roles assigned.
this guess, because -- according debugger -- role claim have type roles
instead of proper namespace http://schemas.microsoft.com/ws/2008/06/identity/claims/role
.
what missing?
did ever working?
i found worked:
claimsidentity id = claimsprincipal.current.identity claimsidentity; var approles = new list<string>(); foreach (claim claim in claimsprincipal.current.claims) { approles.add(claim.value); }
i hope helps similar problem.
Comments
Post a Comment