【发布时间】:2017-12-11 13:00:35
【问题描述】:
我尝试在我的服务中更新用户声明,首先我应该删除这样的声明:
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);
}
但是在RemoveClaim(user.Id,c) 上我得到Collection was modified; enumeration operation may not execute 错误。
我到底做错了什么?
【问题讨论】:
标签: asp.net asp.net-web-api asp.net-identity claims