Azure ad b2c 从dotnet core Razor页面中的Azure AD B2C SUSI用户流捕获显示名称

Azure ad b2c 从dotnet core Razor页面中的Azure AD B2C SUSI用户流捕获显示名称,azure-ad-b2c,Azure Ad B2c,我正在使用Azure B2C和使用Microsoft.Identity.web的dotnet core 3.1 Razor页面web应用程序。我已经运行了它,并且已经能够使用登录。在我的B2C1_susi用户流中,我收集显示名称和电子邮件。我想在my_LoginPartial.cshtml中显示显示名称,而不是User.Identity.Name: <li class="nav-item"> <a class="nav-link text

我正在使用Azure B2C和使用Microsoft.Identity.web的dotnet core 3.1 Razor页面web应用程序。我已经运行了它,并且已经能够使用登录。在我的B2C1_susi用户流中,我收集显示名称和电子邮件。我想在my_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.Name/span>

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

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

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