Copied to clipboard

Flag this post as spam?

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


  • Peter Aderhold 30 posts 202 karma points
    Jan 11, 2020 @ 13:01
    Peter Aderhold
    0

    Server Error only remotely (GetEntityCacheKey)

    Hi Folks

    I really need your help. Since a few days I have a big problem. It seems to me that all started with adding a new user group, but I'm not sure if that was the reason.

    At the moment I get an error viewing my site remotely. This problem doesn't occur locally. The server error is:

    ...[ArgumentNullException: Value cannot be null. Parameter name: id] ...Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.GetEntityCacheKey(Object id)...

    The underlying class seems to be my Navigation.cs which automatically finds some content nodes and builds the navigation.

    public class NavigationController : SurfaceController
    {
        private readonly string _culture;
        private const int NavigationLevel = 3;
        private int _navLevelCounter = 1;
        private const int CategoriesDataTypeId = 1115;
    
        public NavigationController()
        {
            _culture = Umbraco.ContentAtRoot().FirstOrDefault().GetCultureFromDomains();
        }
    
        public ActionResult Navigation()
        {
            var model = GetNavigationItems();
    
            return PartialView("~/Views/Partials/_navigation.cshtml", model);
        }
    
        private List<NavigationModel> GetNavigationItems()
        {
            var rootNavigationItems = new List<IPublishedContent>();
            var home = Umbraco.ContentAtRoot().FirstOrDefault();
            rootNavigationItems.Add(home);
            rootNavigationItems.AddRange(home.Children().Where(x => x.Value<bool>("isRoot") && !x.Value<bool>("hideInNavigation")).ToList());
    
            return rootNavigationItems.Select(GetNavigationModel).ToList();
        }
    
        private NavigationModel GetNavigationModel(IPublishedContent page)
        {
    
            var pageChildren = new List<IPublishedContent>();
            var childNavigationModels = new List<NavigationModel>();
    
            pageChildren = page.Children().Where(x => x.IsVisible() && !x.Value<bool>("isRoot") && !x.Value<bool>("hideInNavigation")).ToList();
    
            if (_navLevelCounter <= NavigationLevel && pageChildren.Any())
            {
                _navLevelCounter++;
                childNavigationModels = pageChildren
                    .Select(GetNavigationModel)
                    .OrderBy(x => x.Category)
                    .ThenBy(x => x.CategoryOrderIndex)
                    .ToList();
                _navLevelCounter--;
            }
    
            var rootParentId = !page.Value<bool>("isRoot") ? page.Ancestors(_navLevelCounter).FirstOrDefault()?.Id : page.Id;
    
            return new NavigationModel
            {
                Text = page.Value<string>("navigationText"),
                MegaMenuImage = page.Value<IPublishedContent>("megaMenuImage")?.Url,
                Link = page.Url,
                UseLink = page.Value<bool>("useLink"),
                Category = Umbraco.GetDictionaryValue(page.Value<string>("navigationCategory")),
                CategoryOrderIndex = page.Value<int>("navigationCategoryOrderIndex"),
                Children = childNavigationModels,
                Id = page.Id,
                RootParentId = rootParentId
            };
        }
    }
    

    This worked perfectely for weeks. Suddenly this error came up.

    All folders got write permissions for the app pool. So where could be the problem? Can/should I turn off the usage of the cache? How?

    I really stuck.

    Thank you for your help.

    Peter

  • Peter Aderhold 30 posts 202 karma points
    Jan 13, 2020 @ 08:33
    Peter Aderhold
    100

    I solved this by removing an obviously broken node. I have no explanation for the issue. The only thing I can imagine is adding a new user group and adding an existing editor to this group during him working on this node...

Please Sign in or register to post replies

Write your reply to:

Draft