2

我正在使用mvc 5,asp.net 4.5,EF 6和标识2.
我遇到了将多个用户数据插入到用户声明中的问题传说 在我的控制器中,成功用户创建我有下面的代码在用户声明表中存储多个用户数据

await UserManager.AddClaimAsync(user.Id, new Claim("FullName", user.FullName)); 

通过这个我只能插入ClaimTypeFullName字符串,并以ClaimValueuser fullname
但我已插入FullNameEmailUserType及其各自的值。

回答

3

要添加多个权利,你可以叫AddClaimAsync每个要求要添加:

await UserManager.AddClaimAsync(user.Id, new Claim("Email", user.Email)); 
await UserManager.AddClaimAsync(user.Id, new Claim("UserType", user.UserType));