Search code examples
asp.net-mvc-4asynchronous.net-4.0sitecoresitecore6

Sitecore: InvalidOperationException: The asynchronous action method 'Search' cannot be executed synchronously


We are using Sitecore 6.6 under .NET 4.0 and using MVC 4 with it. we are trying to implement an asyncontroller and async action within it.

We call this action using an ajax request. we have set up a route to the action and also added that route to the IgnoreUrlPrefixes config property.

however, the same action that works outside of sitecore only ever returns the following exception (stack trace included):

[InvalidOperationException: The asynchronous action method 'Search' cannot be executed synchronously.]
System.Web.Mvc.Async.AsyncActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +133 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39 
System.Web.Mvc.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() +124 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +855026 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +855026 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +309 
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +345 

I have read in the forum that Sitecore executes synchronously (http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=66991).

I am wandering what steps i would need to take to be able to call this action asynchronously from an ajax request?

we are unable to use .NET 4.5 so need to use the old style of async actions rather than using the 'await' keyword

Any help that could be provided would be very helpful.

Thanks


Solution

  • According to the following table, unfortunately, MVC 4 is not supported under Sitecore 6.6, which might be the reason you are seeing these errors: https://kb.sitecore.net/articles/087164