Ninject and WebApi
To use Ninject as the dependecy resolver for WebApi projects you need to:
- Install the following packages:
- Ninject
- Ninject.Web.Common
- Ninject.Web.Common.WebHost
- Ninject.Web.WebApi
- Modify the NinjectWebCommon.CreateKernel method and register an NinjectDependencyResolver as the default dependency resolver.
RegisterServices(kernel);
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
Note NinjectWebCommon is created in the App_Start folder.
References
- http://nodogmablog.bryanhogan.net/2016/04/web-api-2-and-ninject-how-to-make-them-work-together