Skip to content

extension for ninject providing integration with ASP.NET MVC

License

Notifications You must be signed in to change notification settings

moacyr/Ninject.Web.Mvc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

extension for ninject providing integration with ASP.NET MVC

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 92.7%
  • HTML 4.9%
  • CSS 2.3%
  • Classic ASP 0.1%