Tuesday, October 9, 2012

Web Api - Ninject & IHttpControllerActivator

I was reading through the following blog posts today by Mike Seemann:
  • Dependency Injection and Lifetime Management with ASP.NET Web Api
  • Dependency Injection in ASP.NET Web Api with Castle Windsor
In his posts, Mike shows how to use the IHttpControllerActivator to wire up Dependency Injection (DI) without using the built in IDependencyResolver in the Web Api bite. After reading through both of these, I was inspired to create the Ninject based equivalent DI leveraging the IHttpControllerActivator.

Here is the class that I created for this:

A complete sample application is available from https://github.com/paigecook/WebApiNinjectIHttpControllerActivator