I use Ninject on a MVC 5 project with Identity 2.
For rest of data context and controllers using that I have no problems with dependency injection.
For Account controller that uses Identity 2 model I'm getting null UserManager when I try to login:
public class AccountController : Controller
{
private ApplicationUserManager _userManager;
public AccountController()
{
}
public AccountController(ApplicationUserManager userManager)
{
UserManager = userManager;
}
public ApplicationUserManager UserManager {
get
{
return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
What is the proper way to inject required dependencies? I did not create a custom UserManager, it's out of the box model, ApplicationUserManager is as defined in IdentityConfig.cs under App_Start.
As a side note: I'm using Conventions Extension of Ninject:
private static void RegisterServices(IKernel kernel)
{
kernel.Bind(
x => x.FromThisAssembly()
.SelectAllClasses()
.BindAllInterfaces()
);
Thanks.