extension for ninject providing integration with ASP.NET MVC
Clone or download
Latest commit 5f52791 May 15, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src 3.3.0 Oct 23, 2017
.gitignore prepare 3.3.0 Oct 19, 2017
CHANGELOG.md Merge remote-tracking branch 'origin/master' Oct 23, 2017
LICENSE.txt Fixed #46 May 15, 2018
Ninject.Web.Mvc.sln prepare 3.3.0 Oct 19, 2017
README.md prepare 3.3.0 Oct 19, 2017
appveyor.yml Update appveyor.yml Oct 20, 2017

README.md

Ninject.Web.Mvc

Build status NuGet Version NuGet Downloads

This extension allows integration between the Ninject and ASP.NET MVC projects. To use it, just make your HttpApplication (typically in Global.asax.cs) extend NinjectHttpApplication:

public class YourWebApplication : NinjectHttpApplication
{
  public override void OnApplicationStarted()
  {
    // This is only needed in MVC1
    RegisterAllControllersIn("Some.Assembly.Name");
  }

  public override IKernel CreateKernel()
  {
    return new StandardKernel(new SomeModule(), new SomeOtherModule(), ...);
    
    // OR, to automatically load modules:
    
    var kernel = new StandardKernel();
    kernel.AutoLoadModules("~/bin");
    return kernel;
  }
}

Once you do this, your controllers will be activated via Ninject, meaning you can expose dependencies on their constructors (or properties, or methods) to request injections.