Ninject - Asp.net Mvc: multiple projects in solution

I was trying to use Ninject in an Asp.net Mvc application and I was wondering what is the best way to use Ninject if you have more than one project in your solution.

I guess all projects need some kind of Loader, which you initialize in global.asax?

Yours faithfully,

Pickels

+2


a source to share


2 answers


In general, you should only inject the IoC container (in this case Ninject) into the actual executable (or ASP.NET application). Reusable libraries should be agnostic about which container is being used.



To use Ninject in an ASP.NET MVC application specifically, you must use the Ninject factory controller in the Ninject.Web.Mvc extension .

+1


a source


Typically your IoC container is initialized and configured in your entry point project (web project in your case). And yes, this usually happens (directly or indirectly) global.asax. In most cases, you don't need to worry about configuration in any of your other projects.



+1


a source







All Articles