inject pagedatacontext on razor page

lawrence whittemore asked on July 12, 2021 15:01

is it possible to inject the ipagedatacontext into a razor page. I've tried this

@inject IPageDataContext<TreeNode> pageDataContext
<h3>@pageDataContext.Page.Parent.DocumentName</h3>

But I get this error

InvalidOperationException: No service for type 'Kentico.Content.Web.Mvc.IPageDataContext`1[CMS.DocumentEngine.TreeNode]' has been registered.

I'm just trying to get the parent document name.

Correct Answer

lawrence whittemore answered on July 12, 2021 15:33

Figured it out. needed to use IPageDataContextRetriever

0 votesVote for this answer Unmark Correct answer

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