My ASP.Net MVC 4 Web API controller doesn\'t work with Unity.WebApi. In the same project simple controllers works with Unity.Mvc3 properly. But when I run Web API controller
The handling of Controller and ApiController is different as they have completely different base classes:
I use Unity.MVC4 library for controller DI (http://www.nuget.org/packages/Unity.MVC4/)
Install-Package Unity.MVC4
and Unity.WebAPI for DI (http://www.nuget.org/packages/Unity.WebAPI/)
Install-Package Unity.WebAPI
Your bootstrapper should be a combination of both:
DependencyResolver.SetResolver(new Unity.Mvc4.UnityDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
Note I also had to do to add some registration to get the Help page to work
container.RegisterInstance(typeof (HttpConfiguration), GlobalConfiguration.Configuration);
As the owner of Unity.MVC4 I am looking at getting WebApi implemented within our library.