找不到适用于Web API的ApplicationSignInManager和ApplicationUserManager

时间:2018-09-04 21:49:52

标签: c# asp.net-web-api asp.net-identity

我正在尝试使用SignInManager来验证(散列)存储在sql表中的用户密码,这些密码是使用ASP.NET MVC控制器创建的,但是当我通过ASP.NET Web API项目进行尝试时,它会无法解析ApplicationSignInManager或ApplicationUserManager。

这是完成用户验证的方式,还是我应该尝试其他方式?

    private ApplicationSignInManager _signInManager;
    private ApplicationUserManager _userManager;


    public ApplicationSignInManager SignInManager
    {
        get
        {
            return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
        }
        private set 
        { 
            _signInManager = value; 
        }
    }

    public ApplicationUserManager UserManager
    {
        get
        {
            return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
        }
        private set
        {
            _userManager = value;
        }
    }

0 个答案:

没有答案