2

How do I pass a parameter to the processor's constructor AND resolve its dependencies? In the config I have:

<processor type="Feature.ErrorHandling.Pipeline.HttpRequest.PageNotFoundProcessor, Feature.ErrorHandling"
                   resolve="true"
                   patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel']">          
 <param desc="excludeSiteNames">SHELL|ADMIN|LOGIN|SERVICE|MODULES_SHELL|MODULES_WEBSITE</param>            
</processor>

the constructor:

public PageNotFoundProcessor(IErrorPageRepository errorPageRepository, string excludeSiteNames)
{
      _errorPageRepository = errorPageRepository;
      _excludeSiteNames = excludeSiteNames;
}

I receive the following error: Unable to resolve service for type 'System.String' while attempting to activate 'Feature.ErrorHandling.Pipeline.HttpRequest.PageNotFoundProcessor'

1 Answer 1

4

add a public variable with the parameter name and also modify the constructor to only accept the object that needs resolved:

public string ExcludeSiteNames { get; set; }
public PageNotFoundProcessor(IErrorPageRepository errorPageRepository)
{
    _errorPageRepository = errorPageRepository;
}

In the config file, modify it like the following: (note: the pipes were causing it to not map correctly, but commas worked fine)

<processor type="Feature.ErrorHandling.Pipeline.HttpRequest.PageNotFoundProcessor, Feature.ErrorHandling" resolve="true"                   
patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel']">
<ExcludeSiteNames>SHELL,ADMIN,LOGIN,SERVICE,MODULES_SHELL,MODULES_WEBSITE</ExcludeSiteNames>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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