Kentico 10 - asynchronous web part

Cristhian Caldas asked on February 9, 2017 23:17

Hi:

I was implemented a web part wich invokes some asynchronous methods of a third; this web is working in a Kentico 9.0 site ,but it failed when it was implemented in a Kentico 10 site and the page throws the following exception:

An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>. This exception may also indicate an attempt to call an "async void" method, which is generally unsupported within ASP.NET request processing. Instead, the asynchronous method should return a Task, and the caller should await it.

It seems that the solution could be adding Async="true" at the begining of the page, but because of client's policies this solution can't be applied. Do you know another way to solve this issue?

Recent Answers


Michal Samuhel answered on February 10, 2017 09:01

Hi Christian,

Could you post here a piece of the web part call, especially with asynch methods calls and declaration?

I was working with one case when async was enabled with Async="true" , but this created a great deal of problems. Mostly because of a way, how Kentico is handling end of requests and this caused some strange thread was being aborted exceptions.

Moreover asp.net team warns about use of asynch within web forms:

http://www.hanselman.com/blog/TheMagicOfUsingAsynchronousMethodsInASPNET45PlusAnImportantGotcha.aspx

This is why it would be good to see the code of what are we dealing with.

0 votesVote for this answer Mark as a Correct answer

Cristhian Caldas answered on February 10, 2017 17:24

Hi:

The async methods are from a third web service and the web part only invoke these exposed methods :

ex: client.method_async();

0 votesVote for this answer Mark as a Correct answer

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