diff --git a/src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs b/src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs index 5255da652190..8f8473a7e4de 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs @@ -33,11 +33,14 @@ public bool TryFindContent(PublishedRequest frequest) { _logger.Debug("Looking for a page to handle 404."); + int? domainConentId = null; + // try to find a culture as best as we can var errorCulture = CultureInfo.CurrentUICulture; if (frequest.HasDomain) { errorCulture = frequest.Domain.Culture; + domainConentId = frequest.Domain.ContentId; } else { @@ -63,7 +66,9 @@ public bool TryFindContent(PublishedRequest frequest) _contentConfigSection.Error404Collection.ToArray(), _entityService, new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor), - errorCulture); + errorCulture, + domainConentId + ); IPublishedContent content = null; diff --git a/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs b/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs index f2494696cfac..7871a81cc856 100644 --- a/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs +++ b/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs @@ -41,7 +41,8 @@ internal class NotFoundHandlerHelper IContentErrorPage[] error404Collection, IEntityService entityService, IPublishedContentQuery publishedContentQuery, - CultureInfo errorCulture) + CultureInfo errorCulture, + int? domainContentId) { if (error404Collection.Length > 1) { @@ -50,11 +51,11 @@ internal class NotFoundHandlerHelper ?? error404Collection.FirstOrDefault(x => x.Culture == "default"); // there should be a default one! if (cultureErr != null) - return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery); + return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery, domainContentId); } else { - return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery); + return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery, domainContentId); } return null; @@ -67,7 +68,7 @@ internal class NotFoundHandlerHelper /// /// /// - internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery) + internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery, int? domainContentId) { if (errorPage.HasContentId) return errorPage.ContentId; @@ -92,7 +93,7 @@ internal class NotFoundHandlerHelper //we have an xpath statement to execute var xpathResult = UmbracoXPathPathSyntaxParser.ParseXPathQuery( xpathExpression: errorPage.ContentXPath, - nodeContextId: null, + nodeContextId: domainContentId, getPath: nodeid => { var ent = entityService.Get(nodeid);