Good afternoon, ladies and gentlemen! There is a need to call a child action method via @Html.Action() (this is about ASP.NET MVC). Is it possible to do so? The method code is approximately as follows:

 public async Task<ActionResult> Index() { var products = await _productsService.GetAll(CancellationToken.None); return PartialView(departments.ToList()); } 

    1 answer 1

    It is believed that this will lead to problems . Another detailed answer here. The explanation is all, as usual, in English.

    The brief point, as I understand it, is that only the root action can be asynchronous, the children cannot be made asynchronous.

    However, as @andreycha noted, there is a certain ASP.NET vNext (now called ASP.NET Core) in which asynchrony is maintained more holistically with the help of View Components , which completely replace child action .

    It looks very simple:

     public async Task<IViewComponentResult> InvokeAsync() { var profileLinks = await _profileLinkManager.GetAllAsync(); return View(profileLinks); } 

    A more complete description with examples is here .

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky ♦
    • one
      In the last link given by you it is written that it is already fixed. - andreycha
    • one
      @andreycha Not that fixed. It is proposed to use some ASP.NET vNext MVC and its View Components to implement asynchrony in child actions. I add this explicitly to my answer, thanks. - Zverev Evgeniy