I've implemented a custom Resolver for my Controllers for Ninject which works fine, however this is not working for pipelines.

How can I create a custom dependency Injection for Sitecore pipelines?

When I read the anwser below, I think I need to use Factory, but I am not understanding how this works.

I've the following class

public class RedirectResolver : HttpRequestProcessor
    private IWasInjected _injection;

    public RedirectResolver(IWasInjected injection)
        _injection = injection

    public override void Process(HttpRequestArgs args)
        var httpContext = HttpContext.Current;
         //Do Something


this Processor I've registered in the following pipeline

    <processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" type="MyNamespace.RedirectMapResolver, AssemblyName.Feature.Redirects" resolve="true">

thats my current "Implementation" but I don't understand how I get the Factory explained in the blogpost https://cardinalcore.co.uk/2014/07/02/sitecore-pipelines-commands-using-ioc-containers/ to resolve my Injection?

  • What version of Sitecore are you on? And what have you tried so far that isn't working? Mar 19 '19 at 15:36
  • @DanSinclair Sitecore 9 Update 2 and I don't know really what to try, because I don't unterstand how this is working. Mar 19 '19 at 20:21
  • What specifically don't you understand about using a Factory the way Nat detailed in his blog?
    – sitecorium
    Mar 19 '19 at 20:53
  • Currently I've switched to use the service Locator anti Pattern until I understand the pipeline resolving right Mar 20 '19 at 13:33

I have a talk on this :)


Here is the supporting repo for that talk:


You need to use ref= rather than type= and a factory adaptor as you suggest.

Also, I would consider a different DI framework Ninject is very slow, well it was.

Hope that helps, reach out to me on Sitecore Community Chat if you have any issues.

Good luck



When you want to use this pattern (Container Adaptor Factory) with pipeline groups you need to use ref to a config node under types where you deny the ref and the factory it seems.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <group groupName="layoutService">
              <ExampleContextExtension ref="SitecoreJss.Examples.ExampleContextExtension, SitecoreJss.Examples" factory="FactoryContainerAdapter"/>
            <processor ref="ExampleContextExtension">
              <AllowedConfigurations hint="list">
                <!-- Unless you change the Layout Service config used by your JSS app, this should always be present. -->
              <Applications hint="list">
                <!-- Restrict the JSS apps for which this processor will execute. -->
              <Routes hint="list">
                <!-- Restrict the route items for which this processor will execute. IDs, item paths, and wildcard item paths are allowed. -->
  • yes I know Ninject is slow but I need to use it because of our dependent Nuget Packages which all use Ninject. Mar 21 '19 at 7:01
  • All good :), how did you go? I am keen to help you out as I love DI.
    – Gravypower
    Mar 21 '19 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.