1

I found a few posts about this error but non of them fit to my problem. I have a view called DataGrid located in Views/Shared/. This view just renders a table from the model and is meant to be rendered as a partial view with Html.RenderAction(). I have used this in a view called Dynamic.

<h2>Dynamic</h2>

@{
    Html.RenderAction("DataGrid", "Orders", new {gridName = "grid_order"});
};

I created abstract BaseController which contains Get method for my DataGrid view.

public abstract class BaseController : Controller
{
    ...

    public async Task<PartialViewResult> DataGrid(string gridName)
    {
        var model = /* get data from service */

        return PartialView("/Views/Shared/DataGrid.cshtml", model);
    }
}

When I fire the url https://localhost:44300/Orders/Dynamic Html.RenderAction(...) on Dynamic.cshtml is reached and the get method on my BaseController is called. After the code in DataGrid.cshtml is executed (as I debuged it) I get this error:

Zohan.Web.Controllers.ErrorController [(null)] - System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.InvalidOperationException: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)
   at System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues)
   at System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues)
   at ASP._Page_Views_Objednavky_Dynamic_cshtml.Execute() in c:\TFS\Zohan\ZohanSolution\Zohan.Web\Views\Objednavky\Dynamic.cshtml:line 8
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.StartPage.RunPage()
   at System.Web.WebPages.StartPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
   at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

Do I forgot something?

Richard210363
  • 8,342
  • 6
  • 37
  • 63
Smitis
  • 318
  • 1
  • 4
  • 17
  • the await in the call of the render? and also another link: http://stackoverflow.com/questions/24072720/async-partialview-causes-httpserverutility-execute-blocked-exception – sir_ask Mar 13 '17 at 15:40
  • Yes. Just after I posted this question I found that Html.RenderAction can call only sync methods .. – Smitis Mar 13 '17 at 15:45
  • cool.. i guess the link have the answer you need – sir_ask Mar 13 '17 at 15:47
  • Yes. Sometimes it just wants to better read the error message :) – Smitis Mar 13 '17 at 15:50

0 Answers0