在用户声明中存储多个用户数据 Table
Store multiple User data in User Claim Table
我正在使用 mvc 5、asp.net 4.5、EF 6 和 identity 2。
我遇到了将多个用户数据插入 User Claim Tale 的问题
在我的控制器中,成功创建用户后,我有以下代码
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));
我正在使用 mvc 5、asp.net 4.5、EF 6 和 identity 2。
我遇到了将多个用户数据插入 User Claim Tale 的问题
在我的控制器中,成功创建用户后,我有以下代码
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));