Articulate
Articulate copied to clipboard
RSS and Category Pages are giving 404 as in the site I used IContentLastChanceFinder
Hi all
public class My404ContentFinder : IContentLastChanceFinder
{
private readonly IDomainService _domainService;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
public My404ContentFinder(IDomainService domainService, IUmbracoContextAccessor umbracoContextAccessor)
{
_domainService = domainService;
_umbracoContextAccessor = umbracoContextAccessor;
}
public Task<bool> TryFindContent(IPublishedRequestBuilder contentRequest)
{
// Find the root node with a matching domain to the incoming request
var allDomains = _domainService.GetAll(true).ToList();
//var domain = allDomains?
// .FirstOrDefault(f => f.DomainName == contentRequest.Uri.Authority
// || f.DomainName == $"https://{contentRequest.Uri.Authority}"
// || f.DomainName == $"http://{contentRequest.Uri.Authority}");
var domain = allDomains.Where(f => f.DomainName == contentRequest.Uri.Authority
|| f.DomainName == $"https://{contentRequest.Uri.Authority}"
|| f.DomainName == $"http://{contentRequest.Uri.Authority}").FirstOrDefault();
var siteId = domain != null ? domain.RootContentId : allDomains.Any() ? allDomains.FirstOrDefault()?.RootContentId : null;
if (!_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext))
{
return Task.FromResult(false);
}
if (umbracoContext.Content == null)
return new Task<bool>(() => contentRequest.PublishedContent is not null);
var siteRoot = umbracoContext.Content.GetById(false, siteId ?? -1);
if (siteRoot is null)
{
return Task.FromResult(false);
}
// Assuming the 404 page is in the root of the language site with alias fourOhFourPageAlias
var notFoundNode = siteRoot.Children?.FirstOrDefault(f => f.ContentType.Alias == "404");
if (notFoundNode is not null)
{
contentRequest.SetPublishedContent(notFoundNode);
}
// Return true or false depending on whether our custom 404 page was found
return Task.FromResult(contentRequest.PublishedContent is not null);
}
}
builder.SetContentLastChanceFinder<My404ContentFinder>(); I wrote a content finder like above but for the RSS & categories pages are always going to 404.
I understand there is some fundamental routing conflicts going on with Articulate and Umbraco (and potentially other Umbraco Cloud things) which needs to be resolved in the correct way. Using last chance content finders is only a work around and not a viable long term solution.
Unfortunately, I won't have time to help debug this until april since I am away until the end of the month.
@RPanc As a workaround, exclude the Articulate custom routes from your finder, reference this thread.
Note that example routes to filter are not exact, it's still possible to get 404's on some of these routes if wrong node id/data passed, in which case the default Umbraco not found page is served - you can customise/override this with your own template placed in \umbraco\UmbracoWebsite\NotFound.cshtml
You will likely need to build Articulate from latest sources to pick up latest commits that fix or work-around other routing concerns (review commit history/latest PR's to check if these effect you).
Please try the latest Articulate release 5.0.3 and let me know if the problem is resolved.
I can replicate the issue. For now there is a workaround in the other issue. The underlying problem and how to fix is very strange, I'll actually need to debug this with the Umbraco source.