Monday, May 30, 2016

Configure Asp.net MVC 5 with Ninject

Configure Asp.net MVC 5 with Ninject:



How to get Ninject working with asp.net MVC 5

Install-Package Ninject.MVC5  
This will create the file in your solution:
App_Start\NinjectWebCommon.cs  
Then to wire up an interface for resolution to a concreate implementation, just:
private static void RegisterServices(IKernel kernel) {  
    kernel.Bind<ISomeService>().To<SomeConcreateImplementation>();
}  
Unity:Modify UnityConfig.cs to register serviceAdd this to App_start: UnityConfig.RegisterComponents();