Share a Kernel between WebAPI and MVC
问题 I've got a simple MVC4 site which uses ASP.NET webAPI and also MVC pages. I'd like to use Ninject DI for both controller types but I'm wondering how this can be done? I've got Ninject DI working for WebAPI, but now not sure how to share the same Kernel elegantly. Should I be using some sort of Kernel singleton which both Dependency Resolvers can refer to? Anyone had any experience with this? Cheers. 回答1: You should use the same IKernel instance for a single application-level composition root,