What version of Web API are you using? If using the latest version the preferred way would be to use the
Unity bootstrapper for ASP.NET Web API
. Then you would implement a DependencyResolver instead of a ControllerFactory.
I'm not 100% sure I understand how all the components of your application are fitting together. One thing I did see based on the posted registration code is that you need to configure policy injection. Instead of:
You could try:
new Interceptor<InterfaceInterceptor>(), new InterceptionBehavior<PolicyInjectionBehavior>());
Although VirtualMethodInterceptor might be better if the runtime is requesting a concrete controller type (as opposed to an interface).
In general, you want to configure Dependency Injection using Unity with Web API. Once that is wired up (the NuGet package sets up all the hooks) then it is just a matter of configuring the policies; this might be just adding a few lines of registration code
depending on the wiring approach chosen (e.g. programmatic matching rules, attributes, xml configuration).
You also might want to look at MVC/Web API ActionFilters to see if they can help achieve the functionality you are looking for.
Enterprise Library support engineer