Using Ninject with Asp.NET Web API Beta ApiController

前端 未结 5 579
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 22:33

I\'m stuck. I was using the method outlined here for wcf web api p6 Ninject working with WCF Web API Preview 5, however things are quite a bit different with the mvc implementat

5条回答
  •  不要未来只要你来
    2021-01-31 23:09

    I found a nice solution here.

    It's pretty easy if you're already using the Ninject CommonServiceLocator / Bootstrapper:

    private static IKernel CreateKernel() {
       var kernel = new StandardKernel();
       RegisterServices(kernel);
    
       GlobalConfiguration.Configuration.ServiceResolver
          .SetResolver(new NinjectServiceLocator(kernel));
       return kernel; 
    }
    

提交回复
热议问题