【发布时间】:2019-10-02 13:37:30
【问题描述】:
我正在将现有的 .NET Class 项目迁移到 Core。在这里,我们正在尝试从 owincontext 获取当前用户管理器,您能否帮助我们如何在 .NET 核心中实现这一点?
我尝试过使用 HttpContext,但它们不再有 OWINContext 或 GetUserManager()
private CustomStore _myStore;
private MyContext _dbContext;
private AppUserManager _userManager;
private AppRoleManager _roleManager;
public CustomManager(HttpContext ctx)
{
_dbContext = ctx
.GetOwinContext().Get<MyContext>();
_userManager = ctx
.GetOwinContext().GetUserManager<AppUserManager>();
_roleManager = ctx
.GetOwinContext().Get<AppRoleManager>();
}
【问题讨论】:
-
在制作自己的问题之前,请务必检查类似问题。奇怪的是,同样的问题在 3 小时前才被问到:stackoverflow.com/questions/58097042/…。我会将此作为骗子关闭,但目前不能,因为它没有被赞成或接受的答案。
标签: asp.net-core asp.net-identity identityserver4