Ninject : ninject.web - How to apply on a regular ASP.Net Web (!MVC)

Posted by No Body on Stack Overflow See other posts from Stack Overflow or by No Body
Published on 2010-06-17T05:47:56Z Indexed on 2010/06/17 5:53 UTC
Read the original article Hit count: 530

Filed under:
|

What I am looking is something similar to the below (http://github.com/ninject/ninject.web.mvc):

README.markdown

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.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about ninject