How to store the results from GetContentResult() method of EPiserver Find and pass it to other blocks content.

Vote:
 

Hello,

We have news page which contains three blocks and all these make use of GetContentResult() result to display content, so how can we avoid multiple call to GetContentResult() and store the copy of it and use it for all blocks. And whenever editor adds new article to it the result should be updated again. 

Can you please guide how can we avoid multiple calls to GetContentResult()?

#255641
May 27, 2021 16:57
Vote:
 

Hi Deepa

The GetContentResult() results are cached anyway so you are safe to use it on multiple blocks on a page.

See the caching section here: https://world.episerver.com/documentation/developer-guides/search-navigation/Integration/cms-integration/GetContentResult-and-GetFilesResult/ 

David

#255647
May 27, 2021 19:45
Vote:
 

Hi David,

We raised support ticket related to this sometime back and they told don't call GetContentResult() multiple times for same page, copy those result and make use of that copy in other blocks. 

#255683
May 28, 2021 5:03
Vote:
 

Hey Deepa

I am surprised at the advice due to the fact that the documentation says the results are cached. But its likely to avoid multiple hits to the index which is good, so good to learn something new :)

Another option I have not tried is to use the TempData and populate it in the parrent controller then use it for rendering in your block. This isn't ideal as the general best practice is that blocks should be unware and therefore not dependent on the pages they are being used on.

David

#255684
May 28, 2021 7:55
Vote:
 

Hi David,

They reverted back saying there is no harm with GetContentResult() multiple times as it will be cached. For second call cached copy will be used.

Thank you for your input on this.

Deepa

#255811
Edited, May 31, 2021 10:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.