I recently stumbled upon this discussion.
In ASP.NET WebAPI, when we need to integrate a custom container inversion for injection control / dependency, we need to go with two different strategies:
Deploy IHttpControllerActivator, which is an extension point for full control over the life cycle of the controller. That is, we can determine how the controller instance is created. At this point, we can enable the controller using the inverse of the control container, and let it use its own approach to dependency injection.
Inject IDependencyResolverwhere we can determine how to allow dependency injection.
In my current projects, I have come a long way IHttpControllerActivator, and since I use Castle Windsor as the inverse of the control container, I can completely control the life cycle of the object from its container configuration, and I can decide how the controllers will be solved, and the volume of its recursively injected dependencies, which determines that they die when the controller ends its life (i.e. when the request ends) .
Although some of these functions can be achieved through implementations IDependencyResolver, I believe that this IHttpControllerActivatoris the best way to integrate inversion of control and dependencies in the ASP.NET Web API, because I believe that I prefer to stay as far as possible and stick to the Castle Windsor configuration model with point of view of control inversion and dependency injection.
IHttpControllerActivator , IDependencyResolver -API ASP.NET( , Castle Windsor Classes.FromAssembly, , ApiController).
, IDependencyResolver ?