Hi,
Currently, I am having an issue getting current page alias path in Web API project (using ASP.Net Core Web API project). I use IPageDataContextRetriever to retrieve the current TreeNode, however it return following error:
System.InvalidOperationException: 'Missing page context data. If required use IPageDataContextInitializer.Initialize method to initialize the context manually. For POST actions use HtmlHelper extension method Html.Kentico().PageData() to persist the page context.'
I tried to initialize the current page context using IPageDataContextInitializer.Initialize() as suggested above, however it only accept either the page id or TreeNode as parameter which the API does not have info about it.
I can pass the page id from the API caller (jQuery) to the API so I can initialize the page, however I wanna know if there's an easier way to get the current page context in Web API project without have to initialize it.
FYI, I am using Kentico 13.
Thank you if anyone can help with this.
Hadi
Environment
- Xperience by Kentico version: [26.6.0]
- .NET version: [6]
- Deployment environment: [SaaS|Azure|VM]
- Link to relevant Xperience by Kentico documentation