Skip to main content
added 42 characters in body
Source Link
Adam Seabridge
  • 9.4k
  • 1
  • 33
  • 73

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page.

This works fine in my local dev environment but when I deploy it into an Sitecore environment (which has Castle Windsor setup as an IoC) my controller no longer works. The error in the logs is: 'Could not create controller':

public class MyListBrowsingController : Controller
{
    public JsonResult GetItems()
    {
        var myList = //get list here
        return Json(myList, JsonRequestBehavior.AllowGet);
    }

}

As I understand it the problem is that CastleWindsor is wired up via a pipeline and is overwritten the default Sitecore Dependency Resolver, e.g like so:

https://bitlush.com/blog/using-castle-windsor-with-sitecore-mvc-for-dependency-injection

I know ideally this would be solved with a fall-back like so: https://github.com/HedgehogDevelopment/sitecore-chained-dependency-resolver/blob/master/InversionOfControl.CastleWindsor/Pipelines/SetupDependencyResolvers.cs.

However unfortunately I don't have access / control of this code as it's in a separate dll so id like to explicitly register the route in some other way which won't get overwritten by an IoC.

Is there a way to do this?

Further info:

  • Sitecore 7.5 > 8.1

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page.

This works fine in my local dev environment but when I deploy it into an Sitecore environment (which has Castle Windsor setup as an IoC) my controller no longer works. The error in the logs is: 'Could not create controller':

public class MyListBrowsingController : Controller
{
    public JsonResult GetItems()
    {
        var myList = //get list here
        return Json(myList, JsonRequestBehavior.AllowGet);
    }

}

As I understand it the problem is that CastleWindsor is wired up via a pipeline and is overwritten the default Sitecore Dependency Resolver, e.g like so:

https://bitlush.com/blog/using-castle-windsor-with-sitecore-mvc-for-dependency-injection

I know ideally this would be solved with a fall-back like so: https://github.com/HedgehogDevelopment/sitecore-chained-dependency-resolver/blob/master/InversionOfControl.CastleWindsor/Pipelines/SetupDependencyResolvers.cs.

However unfortunately I don't have access / control of this code as it's in a separate dll so id like to explicitly register the route in some other way which won't get overwritten by an IoC.

Is there a way to do this?

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page.

This works fine in my local dev environment but when I deploy it into an Sitecore environment (which has Castle Windsor setup as an IoC) my controller no longer works. The error in the logs is: 'Could not create controller':

public class MyListBrowsingController : Controller
{
    public JsonResult GetItems()
    {
        var myList = //get list here
        return Json(myList, JsonRequestBehavior.AllowGet);
    }

}

As I understand it the problem is that CastleWindsor is wired up via a pipeline and is overwritten the default Sitecore Dependency Resolver, e.g like so:

https://bitlush.com/blog/using-castle-windsor-with-sitecore-mvc-for-dependency-injection

I know ideally this would be solved with a fall-back like so: https://github.com/HedgehogDevelopment/sitecore-chained-dependency-resolver/blob/master/InversionOfControl.CastleWindsor/Pipelines/SetupDependencyResolvers.cs.

However unfortunately I don't have access / control of this code as it's in a separate dll so id like to explicitly register the route in some other way which won't get overwritten by an IoC.

Is there a way to do this?

Further info:

  • Sitecore 7.5 > 8.1
Source Link
Adam Seabridge
  • 9.4k
  • 1
  • 33
  • 73

Custom controller being overwritten by IoC

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page.

This works fine in my local dev environment but when I deploy it into an Sitecore environment (which has Castle Windsor setup as an IoC) my controller no longer works. The error in the logs is: 'Could not create controller':

public class MyListBrowsingController : Controller
{
    public JsonResult GetItems()
    {
        var myList = //get list here
        return Json(myList, JsonRequestBehavior.AllowGet);
    }

}

As I understand it the problem is that CastleWindsor is wired up via a pipeline and is overwritten the default Sitecore Dependency Resolver, e.g like so:

https://bitlush.com/blog/using-castle-windsor-with-sitecore-mvc-for-dependency-injection

I know ideally this would be solved with a fall-back like so: https://github.com/HedgehogDevelopment/sitecore-chained-dependency-resolver/blob/master/InversionOfControl.CastleWindsor/Pipelines/SetupDependencyResolvers.cs.

However unfortunately I don't have access / control of this code as it's in a separate dll so id like to explicitly register the route in some other way which won't get overwritten by an IoC.

Is there a way to do this?