extension for ninject providing integration with ASP.NET MVC
C# CSS ASP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
CHANGELOG.md
LICENSE.txt
Ninject.Web.Mvc.sln
README.md
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.