我想在我的 api 控制器中使用 User.IsInRole() 函式。我有身份用戶,如何將其轉換為 ClaimsPrincipal 或將 User.IsInRole() 與身份用戶一起使用?!?!?!
uj5u.com熱心網友回復:
你可以使用SignInManager<TUser>.CreateUserPrincipalAsync(TUser)方法。
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinmanager-1.createuserprincipalasync?view=aspnetcore-6.0
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/503941.html
標籤:asp.net 核心 asp.net 身份 asp.net-core-3.1
上一篇:在Program.cs中注冊MessageHandler
下一篇:如何獲取當前視圖的url?
