Kentico 13 Beta 2 - DocumentContext gone?

Dražen Janjiček asked on July 28, 2020 09:33

Hi,

While looking at the beta 2, I wanted to see how the new routing works, and thought maybe it resolves the current document already for me and makes it available somewhere. My first attempt was to use the DocumentContext, but it appears to be gone?

Thanks, Drazen

Correct Answer

Dmitry Bastron answered on July 29, 2020 10:29

Hi Drazen,

First of all, please try installing the latest beta version, which is beta 3 now. And have a read in the documentation for beta how to use page type based routing as well as accessing the context document.

DocumentContext was a part of Portal Engine and will be removed in the next version. This is the way to access context document now:

If you need to access the data of the currently requested page, use the Retrieve<TPageType> method of the IPageDataContextRetriever service. The method takes either CMS.DocumentEngine.TreeNode or a page type wrapper class as its generic parameter and returns an IPageDataContext<TPageType> object. Use the object's properties to access the page data:

Page – object representing the page, of the type provided in the generic parameter.

Metadata – provides access to the metadata of the page.

Security – allows you to evaluate the permissions and authentication requirements of the page. See Implementing page permission checks for details.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Dražen Janjiček answered on July 30, 2020 12:20

Thanks. I find it rather strange that I have to retrieve the page on my own in order to initialize the PageDataContext and then work with it, while I already have the TreeNode. Strange concept if you ask me.

0 votesVote for this answer Mark as a Correct answer

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