Here is my api ctor:
public class ContactController : ApiController
// dependency injection is being done here by Unity. look in UnityConfig where we register IContactSevice to ContactService. Whenever asp.net see's IContactService it now knows to make a new ContactService instance
// we do this for 2 reasons: 1) this makes unit testing possible where we can mock the IContactService and 2) this makes maintaining the code easier where we can change the contact service class we want to use later and we wouldn't have to change the code here in this controller
public ContactController(IContactService _service)
service = _service;
public static void RegisterTypes(IUnityContainer container)
The WebAPI controllers have a separate Unity registration. Since you are already using the Unity.MVC package you can add the Unity.AspNet.WebApi bootstrapper.
Since the configuration is automatically replaced, I would save the contents of the
UnityConfig.cs before importing the 2nd package then manually combine the two. But the real differences are in the separate Unity*Activator.cs files.