Asp.net mvc 在用户声明表中存储多个用户数据
我正在使用mvc 5、asp.net 4.5、EF 6和identity 2。Asp.net mvc 在用户声明表中存储多个用户数据,asp.net-mvc,asp.net-mvc-5,entity-framework-6,asp.net-identity-2,Asp.net Mvc,Asp.net Mvc 5,Entity Framework 6,Asp.net Identity 2,我正在使用mvc 5、asp.net 4.5、EF 6和identity 2。 我遇到了在用户声明中插入多个用户数据的问题 在我的控制器中,成功创建用户后,我有以下代码 await UserManager.AddClaimAsync(user.Id, new Claim("FullName", user.FullName)); 这样,我只能在ClaimType列中插入FullName字符串,在ClaimValue中插入user FullName 但是我有insertFullName、Email
我遇到了在用户声明中插入多个用户数据的问题 在我的控制器中,成功创建用户后,我有以下代码
await UserManager.AddClaimAsync(user.Id, new Claim("FullName", user.FullName));
这样,我只能在ClaimType
列中插入FullName
字符串,在ClaimValue
中插入user FullName
但是我有insert
FullName
、Email
和UserType
及其各自的值。要添加多个索赔,您只需为要添加的每个索赔调用addClaimesync即可:
await UserManager.AddClaimAsync(user.Id, new Claim("Email", user.Email));
await UserManager.AddClaimAsync(user.Id, new Claim("UserType", user.UserType));