我在 VS 2010 中使用 MVC4。我有一个异步操作,我正在尝试开始工作。我的控制器继承自 AsyncController 并且我有 ~Async 和 ~Completed 方法。我能够在示例测试项目中正确执行我的异步操作。但是当我将它作为我的核心网络应用程序的一部分运行时,它会出现此异常
[InvalidOperationException:无法同步执行异步操作方法“Complete”。] System.Web.Mvc.Async.AsyncActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 parameters) +133
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 参数) +39
我正在使用 Unity 进行依赖注入、ActionAttributeFilters 和 MVCSiteMapProvider,我想知道其中之一是否会导致上述问题。任何帮助表示赞赏。
谢谢
整个堆栈跟踪
[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