Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Async Controller cannot execute

Vote:
 

Hello, 

we implemented an async block controller in our project, using the approach described here http://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2015/9/async-actionresult/ . We had Epi server version 8.xxx. However, after upgrading to 9.12 this stopped working. We stargted getting errors like:

HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.

It is interesting that async actually works, when inheriting form BlockController. Action results can be async, but they need to be different from Index(). If you have async Index() and inherit from AsyncBlockController, we get the error. 

Additionally, in MVC there is a restriction that child actions cannot be asynchronius. Is it possible Epi server to have changed something in the rendering in the newer version?

#174460
Jan 26, 2017 15:14
Vote:
 

Basically you cannot do async in blocks which are rendered in a content areas. For async to work, everything top-down from the request to your code must be async and MVC does not support it for child actions. When it worked before it probably ran synchronously, blocking the thread anyway.

There are two modes of async in ASP.NET 4.5. One is "compatibility mode" and the other is the new mode which support new async/await pattern and web sockets etc. As of CMS 9 we added a setting(aspnet:UseTaskFriendlySynchronizationContext) in web.config that enables ASP.NET 4.5 mode since it is required to use the new API's.

You can read more about the different modes here: https://blogs.msdn.microsoft.com/webdev/2012/11/19/all-about-httpruntime-targetframework/

#174571
Jan 30, 2017 15:50
* 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.