Reputation: 1241
I'm using ASP.NET 6 MVC Core using VS 2022 community edition. ClaimTypes.NameIdentifier
is working fine but the ClaimTypes.Email
returning null.
string userId = User.FindFirstValue(ClaimTypes.NameIdentifier); working fine
string userEmailAddress = User.FindFirstValue(ClaimTypes.Email); //returning Null.
After a successful transaction from Paypal, I am passing id, email and item details for completing the order. Here is the issue Email is returning null, I think it's a problem in .NET 6.0 and its working fine with the same code in .NET 5.0 (VS 2019) but returning Null in Vs2022
Upvotes: 1
Views: 766
Reputation: 11554
Check User.Claims
to see what claims are available, and if there is a claim with type http://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddress
, then you should expect User.FindFirstValue(ClaimTypes.Email)
returns the value, otherwise claim is missing or check is there is any claim with the Email
type.
Upvotes: 2