2

I am planning to use ASP.NET async pattern in my Sitecore project, but I'm getting the error:

Asynchronous method which returns task as result cannot be executed synchronously

Is there a way to achieve async in Sitecore 8.1?

5

Async controller rendering is not supported . Starting with Sitecore 8.2 async Mvc controllers is supported.

As of 8.2 we support async MVC controllers (directly routed). But async is still not supported for Controller Renderings.

Async only really works when it top to bottom across the stack and there are a number of challenges with various Sitecore APIs not being async (pipelines and data APIs being the big ones).

Ideally SitecoreController.Index should be async and ditto should all calls down to db level. We will need to piecemeal this one.

More information you can find here:

https://sitecorecommunity.uservoice.com/forums/286986-product-sitecore-mvc/suggestions/7321868-async-support

| improve this answer | |
0

You can not use async pattern in Sitecore as it does not support it. If you will try to make it work, you will get exceptions or it will work synchronously. There is a very good article from kamsar on this. Please go through it to understand better. A quick excerpt from the article -

Looking around in the ASP.NET MVC source code, you can see that there are two interfaces for action invokers: IActionInvoker and IAsyncActionInvoker. Guess what? Sitecore’s ActionInvoker implements IActionInvoker but NOT IAsyncActionInvoker - which means that even though the default MVC action invoker it was wrapping supported async invocation, the wrapper’s lack of IAsyncActionInvoker implementation meant ASP.NET MVC wouldn’t use async invocation at all - and would instead throw an error that you cannot return a Task from a synchronous controller

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.