Archive of ‘.NET’ category

Sitecore MVC & Controller Dependency Injection

If you are planning on using DI on your Sitecore 7.2 and later projects, you should be aware that Sitecore has itself started using MVC in some of it’s features. For example, if on an image field you click “Browse”, then “Upload”, this diaglog window will call the URL /api/sitecore/Media/Upload?sc_database=master which is an MVC route.

The issue is, if you have set the Controller Factory of your application to your own (this was done when using a Castle Windsor implementation) then you need to ensure you have registered the instances of IController within the Sitecore DLLs as well as your own. The DLLs you need to register are Sitecore.Speak.ClientSitecore.Mvc and Sitecore.Mvc.DeviceSimulator. For example, in Castle Windsor you would need to add something like the following to your Installer which registers your controllers:

For further reading, look at Sitecore support ticket #429145