IPageDataContextRetriever Getting different data in the Admin than in the Live Site

Michael Webb asked on April 5, 2023 19:54


So, we have a site that is using Content tree-based routing and we are utilizing the IPageDataContextRetriever to get information about which page we are on. This is retrieved in a few places including in a HeaderViewComponent. The live site is targeting .NET 6.

This site has a slightly complex hierarchy, where each detail page, after being inserted, finds a specific parent node of a SubRootLevel page type. The parent page's NodeID and NodeGUID are then saved to each individual page. The page fields look similar to this:

Detail page [fieldName: dataType]
  - SubRootNodeID: int    // Saved from the custom sub-root page
  - SubRootNodeGUID: Guid // Saved from the custom sub-root page
  - DetailTitle: string
  - ... other detail page fields ...

The sub-root ID and GUID are saved in an event handler on the CMS side for the DocumentEvents.Insert.Before and DocumentEvents.Update.After event handlers for all detail pages.

The Main Issue

This is all working correctly, sub-root page IDs/GUIDs are saved correctly and in the live site calling IPageDataContextRetriever.TryRetrieve(out IPageDataContext<TreeNode> nodeContext) successfully pulls the correct page data and the correct values for SubRootNodeID and SubRootNodeGUID.

But, in the CMS/Admin, viewing the page in Page Builder, it is pulling all correct data except it is getting incorrect values for SubRootNodeID and SubRootNodeGUID. This looks like it happens when one of the SubRootNodes in the tree is copied along with it's children.

Checking the database, the new ID and GUID are set correctly into each child node and, again, the live site pulls the correct context data including those IDs in each copied child node. I have tried the following to reset/refresh the Admin's version of the page data context with no success:

  • Attempting to re-trigger the event handlers for these pages
  • Clearing the System cache
  • Clearing the Debug System object Hash Tables
  • Clearing the Admin cache under Debug / Cache items / Administration / Clear cache (button)
  • Recycling IIS AppPool and restarting the IIS site (in IIS and on the System page)

Now, if I insert new nodes under that new SubRootNode the ID/GUID in the Admin's page data context, for the new node is correct, but something about the data context of the copied child pages in Kentico Page Builder is not getting the new data and is getting stuck somewhere.

I know this is fairly complex, but any push in the right direction is helpful.

Main Question (tl;dr)

What exactly is the difference in Kentico's Admin PageDataContext and the one in the live site? How can I get the CMS Page Builder version of the PageDataContext in Page Builder to refresh and correctly match the database data/live site

   Please, sign in to be able to submit a new answer.