Search code examples
kentico

Kentico 11 Portal Page Template - how to set Page AsyncMode?


I have a custom webpart that is inside a Portal Page template. It needs to call an async web api method on a button click.

I know for an ASPX based template we would see the Page property like:

<%@ Page Title="" Language="C#" ...... Async="true" %>

But I'm not sure if this is accessible using portal template.

If it's not possible and I have to create an ASPX template - is it possible for it to reference a portal based masterPage or would I have to pull that out into an aspx page too?

The reason I need this property set is support this code:

protected void btnProcessPayment_Click(object sender, EventArgs e)
{
   Page.RegisterAsyncTask(new PageAsyncTask(ExecuteValidation));
}

private async Task ExecuteValidation()
{

I have found this to be a reliable implementation in web forms.


Solution

  • Although I am not sure that you can set a whole page as Async, there are other options here.

    1. You could use Kentico's AsyncControl - this control is used throughout the admin interface for asynchronous processing

    2. You could use Kentico's AsyncWorker - if for some reason you cannot use the AsyncControl this can be a valid alternative