[英]User.FindFirstValue(ClaimTypes.Email) in ASP.NET MVC Core 6 using VS 2022 returns Null
I'm using ASP.NET 6 MVC Core using VS 2022 community edition.我正在使用 VS 2022 社区版的 ASP.NET 6 MVC 核心。 ClaimTypes.NameIdentifier
is working fine but the ClaimTypes.Email
returning null. ClaimTypes.NameIdentifier
工作正常,但ClaimTypes.Email
返回 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.从 Paypal 成功交易后,我传递 id、email 和项目详细信息以完成订单。 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 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
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.检查User.Claims
以查看可用的声明,如果有类型为http://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddress
的声明,那么您应该期望User.FindFirstValue(ClaimTypes.Email)
返回值,否则缺少声明或检查是否有任何Email
类型的声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.