Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel 2 posts 72 karma points
    Jun 03, 2019 @ 09:53
    Daniel
    0

    multi site, randomly wrong content

    Hi! We are running a multi site, i.e. one Umbraco Instance to Host Multiple Sites/domains (one language).

    Problem is that some content, like menus and loggo are randomly being displayed using another node/site's content. This happens only sometimes and cant find a way to reproduce on local environment or production.

    A guess is that either code like this get wrong value: Home = currentPage.AncestorOrSelf(1) as Home or currentPage is from the wrong site node.

    This seem to be most frequent, but not only on that page, on a page where there is a custom IContentFinder to find the relevant page:

    public class NotFoundContentFinder : IContentFinder
    {
        private string _domainRoutePrefixId;
    
        public bool TryFindContent(PublishedContentRequest contentRequest)
        {
            var uri = contentRequest.Uri.GetAbsolutePathDecoded();
    
            var ds = ApplicationContext.Current.Services.DomainService;
            var domains = ds.GetAll(true) as IList<IDomain> ?? ds.GetAll(true).ToList();
            _domainRoutePrefixId = String.Empty;
            if (domains.Any())
            {
    
                IDomain domain = null;
                foreach (IDomain currentDomain in domains)
                {
                    if (currentDomain.DomainName.ToLower().StartsWith("http") && contentRequest.Uri.AbsoluteUri.ToLower().StartsWith(currentDomain.DomainName.ToLower()))
                    {
                        domain = currentDomain;
                        break;
                    }
                    else if ((contentRequest.Uri.Authority.ToLower() + contentRequest.Uri.AbsolutePath.ToLower()).StartsWith(currentDomain.DomainName.ToLower()))
                    {
                        domain = currentDomain;
                        break;
                    }
                }
    
                if (domain != null)
                {
    
                    _domainRoutePrefixId = domain.RootContentId.ToString();
                }
            }
    
            //closestContent not used in code later
            var closestContent = UmbracoContext.Current.ContentCache.GetByRoute(_domainRoutePrefixId + uri.ToString(), false);
            while (closestContent == null)
            {
                uri = uri.Remove(uri.Length - 1, 1);
                closestContent = UmbracoContext.Current.ContentCache.GetByRoute(_domainRoutePrefixId + uri.ToString(), false);
            }
    
    
            var productPage = GetProductPage(closestContent.Id);
            if (productPage != null)
            {
                contentRequest.PublishedContent = productPage;
                return true;
            }
    
            //  removed some code for brewity
    
    
            return true;
        }
    
        private IPublishedContent GetProductPage(int id)
        {
            //yeah I know, id not used here
            var home = GetHomePage();
            if (home != null)
            {
                var pp = home.ProductPage;
                if (pp != null)
                    return pp;
            }
    
            return null;
        }
    
    
        private Home GetHomePage()
        {
            //is this returning wrong node sometimes?
            var home = UmbracoContext.Current.ContentCache.GetByRoute(_domainRoutePrefixId + "/", false) as Home;
            return home;
        }
    }
    
    public class ContentFinderStartUp : ApplicationEventHandler
    {
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByNotFoundHandlers, NotFoundContentFinder>();
        }
    }
    

    Running on Azure

    Umbraco version 7.8.1

    web.config settings:

    key="umbracoConfigurationStatus" value="7.8.1" key="umbracoHideTopLevelNodeFromPath" value="true" key="umbracoUseDirectoryUrls" value="true" key="umbracoTimeOutInMinutes" value="20" key="umbracoDefaultUILanguage" value="en-US" key="umbracoUseSSL" value="true"

    umbraco.config settings:

    useDomainPrefixes =true addTrailingSlash=true urlReplacing toAscii="true"

    trySkipIisCustomErrors="true" internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false" umbracoApplicationUrl="" disableRedirectUrlTracking="true"

  • Peter Gregory 407 posts 1611 karma points MVP 3x admin c-trib
    Sep 28, 2020 @ 02:30
    Peter Gregory
    0

    Did you ever resolve this issue? We are seeing a similar behavior with Umbraco 8 on azure when running with a multisite setup.

Please Sign in or register to post replies

Write your reply to:

Draft