我正在使用 mvc 5、asp.net 4.5、EF 6 和 Identity 2。
我遇到了将多个用户数据插入用户声明故事的问题
在我的 Controller 中,成功创建用户后,我有以下代码
await UserManager.AddClaimAsync(user.Id, new Claim("FullName", user.FullName));
这样我只能在 ClaimType
列中插入 FullName
字符串,在 ClaimValue
中插入 user fullname
。
但我插入了 FullName
、Email
和 UserType
及其各自的值。
最佳答案
要添加多个声明,您只需为要添加的每个声明调用 AddClaimAsync:
await UserManager.AddClaimAsync(user.Id, new Claim("Email", user.Email));
await UserManager.AddClaimAsync(user.Id, new Claim("UserType", user.UserType));
关于asp.net-mvc - 在用户声明表中存储多个用户数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35729519/