我在VS 2010中使用了MVC4。我有一個異步操作,我嘗試工作。我的控制器從AsyncController繼承,我有〜異步和〜完成的方法。我能夠在示例測試項目中正確執行我的異步操作。但是,當我運行它作爲我的核心web應用程序的一部分,它讓這個異常MVC異步錯誤 - 異步操作方法'Complete'不能同步執行
[InvalidOperationException異常:異步操作方法「完全」不能同步執行] System.Web.Mvc.Async.AsyncActionDescriptor.Execute(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
是的,那是問題所在。感謝您指出了這一點! – Joy 2013-03-24 15:56:14
它以什麼方式導致問題? – 2014-04-02 17:20:00
最新版本的NotFoundMVC支持異步 – 2017-05-08 12:43:23