简体   繁体   English

ASP.NET MVC Core 6 中的 User.FindFirstValue(ClaimTypes.Email) 使用 VS 2022 返回 Null

[英]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

从 Paypal 成功交易后,我将传递 ID、电子邮件和项目详细信息以完成订单。这是电子邮件返回 Null 的问题,我认为这是 .NET 6.0 中的一个问题,它在 .NET 5.0(VS 2019)中使用相同的代码可以正常工作,但在 Vs2022 中返回 Null

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.

相关问题 TypeScript React 应用在 ASP.NET Core 6.0 with VS 2022 - TypeScript React Application in ASP.NET Core 6.0 with VS 2022 Azure B2C 检查用户 email Id 是否存在或不使用 ASP.NET Core 3.1 MVC 中的图表 - Azure B2C check user email Id exists or not using Graph in ASP.NET Core 3.1 MVC ASP.NET MVC 5(非 MVC 核心)TempData 在 Azure AppService 环境之一中不起作用并返回 null 值 - ASP.NET MVC 5 (Not MVC Core) TempData is not working in one of the Azure AppService Environment and returns null value 使用asp.net mvc发送电子邮件 - Send EMail using asp.net mvc 在 ASP.NET MVC 中使用 ASP.NET Core IServiceCollection - Using ASP.NET Core IServiceCollection in ASP.NET MVC 在 asp.net MVC 5(非核心)中使用 IDataProtectionProvider - Using IDataProtectionProvider in asp.net MVC 5 (not core) 在 Asp.Net Mvc Core 中调用存储库模式方法返回 null - Calling Repository Pattern methods returns null in Asp.Net Mvc Core Asp.net 核心 blazor 与 Z2D50972FECD376129545507F1062089Z 核心 mvc 与 Z60C05C632A2822A0A8477C7E9916 - Asp.net core blazor vs .net core mvc with razor ASP.NET MVC - 登录成功,但userId返回null - ASP.NET MVC - Login Success, but userId returns null CheckBox在ASP.NET MVC中始终返回null - CheckBox always returns null in ASP.NET MVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM