[英]Is the current user Id accessible in an ASP.NET Core 5 MVC controller if the project uses Azure AD?
My site is using Azure AD for authentication I see that User.Identity.Name
is available and I was wondering if the Guid uid
is available in a similar fashion?我的站点使用 Azure AD 进行身份验证我看到User.Identity.Name
可用,我想知道 Guid uid
是否以类似的方式可用?
Thanks谢谢
One of the workaround could able to get the current user id from ASP.NET core MVC application.解决方法之一可以从 ASP.NET 核心 MVC 应用程序获取当前用户 ID。
We need to use the below:我们需要使用以下内容:
using Microsoft.AspNet.Identity;
Instead of using User.Identity.Name
use this cmd
User.Identity.GetUserId();
而不是使用User.Identity.Name
使用这个cmd
User.Identity.GetUserId();
For more information please refer this SO THREAD有关更多信息,请参阅此SO 线程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.