IContentFinder
Information about creating your own content finders
public interface IContentFinder
{
Task<bool> TryFindContent(IPublishedRequestBuilder contentRequest);
}Example
public class MyContentFinder : IContentFinder
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
public MyContentFinder(IUmbracoContextAccessor umbracoContextAccessor)
{
_umbracoContextAccessor = umbracoContextAccessor;
}
public Task<bool> TryFindContent(IPublishedRequestBuilder contentRequest)
{
var path = contentRequest.Uri.GetAbsolutePathDecoded();
if (path.StartsWith("/woot") is false)
{
return Task.FromResult(false); // Not found
}
if (!_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
return Task.FromResult(false);
}
// Have we got a node with ID 1234
var content = umbracoContext.Content.GetById(1234);
if (content is null)
{
// If not found, let another IContentFinder in the collection try.
return Task.FromResult(false);
}
// If content is found, then render that node
contentRequest.SetPublishedContent(content);
return Task.FromResult(true);
}
}Adding and removing IContentFinders
Umbraco builder extension
Composer
NotFoundHandlers
Last updated
Was this helpful?