i Try to update user claims in my service and at the first i should remove claims like this:
var userClaimCollection = this.AppUserManager.GetClaims(user.Id);
var toRemove = new List<Claim>();
foreach (var claim in userClaimCollection)
{
if (claim.Type == group_role)
{
toRemove.Add(claim);
}
}
foreach(var t in toRemove)
{
Claim c = new Claim(group_role, t.Value);
this.AppUserManager.RemoveClaim(user.Id, c);
}
but on RemoveClaim(user.Id,c)
i get Collection was modified; enumeration operation may not execute
error.
what really am i doing wrong?
at the end i found my problem that was Identity 2.2.0 and after update to Identity 2.2.1 my problem solved.
i found my answer here