Configure Unity DI for ASP.NET Identity

后端 未结 4 762
花落未央
花落未央 2020-12-01 13:08

I\'m using Unity successfully for all regular constructor injection such as repositories etc., but I can\'t get it working with the ASP.NET Identity classes. The setup is th

4条回答
  •  半阙折子戏
    2020-12-01 13:13

    Replace this property in the AccountController

    public ApplicationUserManager UserManager
    {
        get
        { 
            _userManager = new ApplicationUserManager(
                              new UserStore(new ApplicationDbContext()));
            return _userManager ??
                   Request.GetOwinContext().GetUserManager();
        }
        private set
        {
            _userManager = value;
        }
    }
    

提交回复
热议问题