Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting "No controller returned error" from Ninject only in certain environments with MVC 3 application
    primarykey
    data
    text
    <p>I am currently creating an MVC3 application using Ninject. I have two controllers which get injected with a repository by Ninject, both of which work fine on my local machine. </p> <p>However, when I deploy them to my remote web server, I get <code>The IControllerFactory 'Inventory.Infrastructure.NinjectControllerFactory' did not return a controller for the name 'GetOptions'.</code> as an error, but only when I hit one of the controllers - the other works fine. Is there something that I'm doing wrong here? I'm pretty new to Ninject and DI so if there is another way I should be going about this, please let me know. Thanks!</p> <p>Here is my controller factory</p> <pre><code>public class NinjectControllerFactory : DefaultControllerFactory { private IKernel ninjectKernel; public NinjectControllerFactory() { ninjectKernel = new StandardKernel(); AddBindings(); } protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType); } private void AddBindings() { ninjectKernel.Bind&lt;IVehicleRepository&gt;().To&lt;EFVehicleRepository&gt;(); } } </code></pre> <p>In Application_Start I have:</p> <pre><code>ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory()); </code></pre> <p>And last, my controllers are</p> <pre><code>public class InventoryAPIController : Controller { IVehicleRepository repository; public InventoryAPIController(IVehicleRepository repo) { repository = repo; } } </code></pre> <p>and </p> <pre><code>public class VehicleController : Controller { IVehicleRepository repository; public VehicleController(IVehicleRepository repo) { repository = repo; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload