Hi Everyone,
I’m creating a ContentFinder which decorates and replaces the core content finders, to do a few things like redirect in order to add the trailing slash, or redirect to another page etc.
The following code works ok,
public CanonicalContentFinder(ILogger<CanonicalContentFinder> logger,
ILogger<ContentFinderByIdPath> loggerForFinderByIdPath,
ILogger<ContentFinderByUrl> loggerForFinderByUrl,
IOptions<Umbraco.Cms.Core.Configuration.Models.WebRoutingSettings> options,
IRequestAccessor requestAccessor,
IUmbracoContextAccessor umbracoContextAccessor)
{
_logger = logger;
_finderByUrl = new ContentFinderByUrl(loggerForFinderByUrl, umbracoContextAccessor);
_finderByIdPath = new ContentFinderByIdPath(options, loggerForFinderByIdPath, requestAccessor, umbracoContextAccessor);
}
However, I feel un-easy newing up those core content finders,
I tried asking for them via constructor parameters but
I get this error:
AggregateException: Some services are not able to be constructed
(Error while validating the service descriptor ‘ServiceType:
Dls.ContentFinders.CanonicalContentFinder Lifetime: Singleton
ImplementationType: Dls.ContentFinders.CanonicalContentFinder’: Unable
to resolve service for type
‘Umbraco.Cms.Core.Routing.ContentFinderByUrl’ while attempting to
activate ‘Dls.ContentFinders.CanonicalContentFinder’.)
Does anyone have any advice?
Cheers.
Murray.
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/107307-optimise-my-contentfinder-decorator-in-v9