After a user is authenticated into my Azure AD B2C web application, I attempt to retrieve User.Identity.Name
; however, it is null. Yet, User.Identity.m_instance_claims[9]
, as shown in the screenshot below, does correctly have the name.
How can this be? How can I get User.Identity.Name
= User.Identity.m_instance_claims[9]
?
(Note that the latter is a private variable, and it cannot be used as a substitute for User.Identity.Name
.
UPDATE
I have also added the following to the Web.config
file:
<configuration>
<configSections>
<!--WIF 4.5 sections -->
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</configSections>
...
<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<add type="System.IdentityModel.Tokens.SamlSecurityTokenHandler, System.IdentityModel">
<samlSecurityTokenRequirement>
<nameClaimType value="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" />
</samlSecurityTokenRequirement>
</add>
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
</configuration>
Unfortunately, this still gives User.Identity.Name = null
.