MVC 3 inject Controllers with Ninject
I can't seem to find an example of injecting controllers directly from a seperate project. Previously in Spring.net I would add the following to the Global.asax
and then simply add the entry to the xml <object name="Shared" type="..."/>
Could someone please outline the steps I need to take to accomplish this with the latest version of Ninject and MVC3? or a link to an example?
Addtionally I was wanting to do something similair with the Views (put them in a seperate project), can Ninject help me with this?
Any help appreciated.
Have you tried using the Ninject.Mvc3 package? It will set up everything for you: http://nuget.org/List/Packages/Ninject.MVC3.
Install it by typing: Install-Package Ninject.Mvc3 in the Package Manager Console. It will add a file under the App_Start folder, there you can modify what you want to inject.
For the View part Ninject can help you if you have implemented your own IViewPageActivator that you inject. But why do you want to have your views in a separate project? The views belongs to the web application and should be located in the web application project.
Read the Ninject.MVC documentation: https://github.com/ninject/ninject.web.mvc/wiki/Setting-up-an-MVC3-application