OutCust / Ninject.Web.Mvc

extension for ninject providing integration with ASP.NET MVC

Home Page:http://ninject.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This extension allows integration between the Ninject core 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

http://ninject.org/


Languages

Language:C# 88.2%Language:ASP 4.5%Language:CSS 4.0%Language:Batchfile 3.3%