【问题标题】:Store multiple User data in User Claim Table在用户声明表中存储多个用户数据
【发布时间】:2016-06-14 06:15:55
【问题描述】:

我正在使用 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
但我插入了FullNameEmailUserType 以及它们各自的值。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-5 entity-framework-6 asp.net-identity-2


    【解决方案1】:

    要添加多个声明,您只需为要添加的每个声明调用 AddClaimAsync:

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

    【讨论】:

      猜你喜欢
      • 2015-09-04
      • 2019-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多