我真的堅持這一點。Html.Action引發「異步操作」InvalidOperationException
我的ActionResult是如下
public ActionResult HolidayReport()
{
return View("~/Views/Employee/GetEmployeeHolidayReport.cshtml");
}
目前擁有的
<div class="panel panel-default panel-main">
<div class="panel-body">
@{ Html.RenderAction("Test"); }
</div>
</div>
視圖內容完成的緣故,這是Test
行動
public ActionResult Test()
{
return new EmptyResult();
}
甚至沒有去控制器或其他任何類型的東西都會拋出異常
An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>. This exception may also indicate an attempt to call an "async void" method, which is generally unsupported within ASP.NET request processing. Instead, the asynchronous method should return a Task, and the caller should await it.
關於@{ Html.RenderAction("Test"); }
部分在視圖中。 交換@ Html.Action()導致同樣的問題。可能會發生什麼?
發佈您的「測試」操作。 – mxmissile
它甚至沒有進入控制器,我已經嘗試了不同的操作。異步任務和常規ActionResult –
Perry