【问题标题】:Capture Display Name from Azure AD B2C SUSI user flow in dotnet core Razor Page从 dotnet core Razor 页面中的 Azure AD B2C SUSI 用户流捕获显示名称
【发布时间】:2020-10-04 03:53:46
【问题描述】:

我正在使用带有 Microsoft.Identity.Web 的 dotnet core 3.1 Razor Page Web 应用程序的 Azure B2C。我已经运行它并且能够使用latest templates 登录。在我的 B2C1_susi 用户流程中,我收集了显示名称和电子邮件。我想在我的 _LoginPartial.cshtml 中显示显示名称,而不是 User.Identity.Name:

<li class="nav-item">
     <a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="EditProfile">
          <span class="text-dark">Hello @User.Identity.Name!/span>
     </a>
</li>

如何向 User.Identity 添加其他字段并让他们从注册/登录用户流程中捕获显示名称和电子邮件?

【问题讨论】:

    标签: azure-ad-b2c


    【解决方案1】:

    在 ASP.Net Core 3.1 Razor 页面中,您可以使用 @User.FindFirst("ClaimName").Value 显示在令牌中返回的所有必需的用户声明。

    例如,@User.FindFirst("emails").Value 可用于显示电子邮件声明,对于显示名称,您也可以使用 @User.GetDisplayName()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-11
      • 2017-11-24
      • 1970-01-01
      • 2019-11-19
      • 2021-07-25
      • 2022-10-02
      相关资源
      最近更新 更多