MVC Async error - The asynchronous action method 'Complete' cannot be executed synchronously

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

I am using MVC4 with VS 2010. I have an async action that I am trying to get working. My controller inherits from AsyncController and I have the ~Async and ~Completed methods. I am able to execute my async action correctly in a sample test project. But when I run it as part of my core web app it get this exception

[InvalidOperationException: The asynchronous action method 'Complete' cannot be executed synchronously.] System.Web.Mvc.Async.AsyncActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +133 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39

I am using Unity for Dependency Injection, ActionAttributeFilters and MVCSiteMapProvider, I am wondering if one of these is causing the above issue. Any help is appreciated.

Thanks

The whole stack trace

[InvalidOperationException: The asynchronous action method 'Complete' 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() +129 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +978122 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +978400 NotFoundMvc.ActionInvokerWrapper.InvokeActionWith404Catch(ControllerContext controllerContext, String actionName) in c:\Users\Andrew Davey\projects\opensource\NotFoundMvc\src\NotFoundMvc\ActionInvokerWrapper.cs:40 NotFoundMvc.ActionInvokerWrapper.InvokeAction(ControllerContext controllerContext, String actionName) in c:\Users\Andrew Davey\projects\opensource\NotFoundMvc\src\NotFoundMvc\ActionInvokerWrapper.cs:21 System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +67 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +53 System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +53 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

回答1:

It looks like the NotFoundMVC Lib cause this problem. uninstall this package you will get work fine!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!