![](/img/trans.png)
[英]Is there a way to authenticate an ASP.NET Core MVC controller action using an Azure AD token?
[英]Is the current user Id accessible in an ASP.NET Core 5 MVC controller if the project uses Azure AD?
我的站點使用 Azure AD 進行身份驗證我看到User.Identity.Name
可用,我想知道 Guid uid
是否以類似的方式可用?
謝謝
解決方法之一可以從 ASP.NET 核心 MVC 應用程序獲取當前用戶 ID。
我們需要使用以下內容:
using Microsoft.AspNet.Identity;
而不是使用User.Identity.Name
使用這個cmd
User.Identity.GetUserId();
有關更多信息,請參閱此SO 線程
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.