Reputation: 151
I am using the NuGet add the Ninject and Ninject.Web.Mvc reference to my project. but i don't add register code for the controller(with a parameter constructor) binding. but it seems the controller was created correctly, i wonder how Ninject create the controller with dependency parameter withou register the controller to the ninject. in the Ninject.Web.Mvc, and i found the following sentense in the author (ninject) 's blog,
The controller itself will be found by Ninject even without adding a binding. Of course, you can still add a binding for the controller in case you need to specify more information for the binding (e.g. an additional constructor argument). i found a similar questions, How does Ninject create controller in ASP.NET MVC? the answer saids: Ninject finds constructor for this type, injects parameters, returns controller instance
my question is : if we don't register the controller how did the NinjectResolver resolve the controller?
Upvotes: 1
Views: 686
Reputation: 32725
non-abstract
classes (such as controllers) are resolved by ninject by default as Bind<TheType>().ToSelf()
if there is no binding.
Upvotes: 3