There is an issue of AccountController instantiation due to the dependencies of ApplicationUserManager, UserStore in asp .net Web api. I am able to succesfully register all other dependencies for simple injector DI.
I have searched a number of places to inject the right instances/types but could not conclusively do it properly yet.
Is there a way for me to ignore the default RegisterWebApiControllers given by simple injector so that I can avoid instantiating the AccountController via simple injector? Of is it impractical?
Just get rid of the AccountController
's default constructor. It is as simple as that.
Another option is to override the AccountController
registration as follows:
container.RegisterWebApiControllers(config);
container.Options.AllowOverridingRegistrations = true;
container.Register<AccountController>(() => new AccountController());
container.Options.AllowOverridingRegistrations = false;
Here are some interesting reads when using Identity with Simple Injector: