Can anybody point me in the right direction to get Ninject working with WCF Web API Preview 5? I have it successfully up and running in my ASP.NET MVC 3 project and also in
Following is my code with Ninject and WebApi,it works. Create a class inherites from WebApiConfiguration
public class NinjectWebApiConfiguration : WebApiConfiguration {
private IKernel kernel = new StandardKernel();
public NinjectWebApiConfiguration() {
AddBindings();
CreateInstance = (serviceType, context, request) => kernel.Get(serviceType);
}
private void AddBindings() {
kernel.Bind().To();
}
}
and use the NinjectWebApiConfiguration in RegisterRoutes
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
var config = new NinjectWebApiConfiguration() {
EnableTestClient = true
};
routes.MapServiceRoute("api/contacts", config);
}