0

I currently have no problem with injecting into the controllers that inherit from the ApiController. However when I try the standard controller the error concerning a parameterless constructor occurs.

I understand that the following:

 GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel);

only sets the injection for the controllers inheriting from the ApiController.

My question is, what do i need to do to enable the controllers inheriting form teh Controller class to access the Ninject resolver?

  • Possible duplicate, check this answer I gave http://stackoverflow.com/questions/21520417/share-a-kernel-between-webapi-and-mvc/21528440#21528440 – cvbarros Mar 19 '14 at 00:45
  • Are you using nuget to install ninject? What is package name? – sunil Mar 19 '14 at 17:53

1 Answers1

0

you need to have a different dependency resolver for normal mvc controllers.

http://www.asp.net/mvc/tutorials/hands-on-labs/aspnet-mvc-4-dependency-injection

Duy
  • 1,332
  • 1
  • 10
  • 19