A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Using AsyncBlockComponent to write async code?

Vote:
 

Hi,

With later versions of Episerver/Optimizely, we've been given a abstraction called AsyncBlockComponent. According to the documentation, the purpose is "Provides the base implementation for asynchronus block components". I think that it's existence leads the developer into thinking this is a way to write true async code. Async child actions (= blocks) was maybe not allowed in .NET Framework, but this is no longer the case in .NET Core... I think, at least.

But! On the other hand, true async code must use async all the way or task return types, but using Html.PropertyFor(...) to render a content area is neither of them.

Digging deeper, I can see that rendering a content area is done via the method below (see bottom of post). Execution of block components are wrapped in a GetAwaiter().GetResult() context, which is NOT async code. Rather, this leads to deadlocks and downtime. 

In our scenario, we have a product recommendations blocks that render user-unique recommendations fetched from a REST API.

I guess I have three questions - is my understanding correct, was everyone aware of this, and, how do you solve the problem?

  public static void RenderContentData(
    this IHtmlHelper html,
    IContentData contentData,
    bool isContentInContentArea,
    TemplateModel templateModel,
    IContentRenderer contentRenderer)
  {
    html.ViewContext.HttpContext.RequestServices.GetRequiredService<HtmlGenerator>().RenderContentDataAsync(contentData, html.ViewContext, isContentInContentArea, templateModel, (string) null, contentRenderer).GetAwaiter().GetResult();
  }
#341535
Jan 28, 2026 12:39
Eric Herlitz - Jan 28, 2026 15:14
A lot of the implementations in CMS/Commerce/Etc nowadays doesn't only have the Html.PropertyFor as intended usecase. If you want true async there's no reason to lean on MVC-standards anyway?
Andreas Jilvero - Jan 28, 2026 15:28
@Eric I'm sorry, I don't understand what you mean. Care to clarify? 😅
* 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.