0

I have an action in the controller to load data for Partial view as below:

    public async Task<IActionResult> ParentTutorCountByLocation()
    {
        var result = await this.dashboardService.GetParentTutorCountPerLocation();
        return this.PartialView("Dashboard/ParentTutorCountByLocation", result);
    }

I've to call it over another view:

tried, renderPartialAsync, Partial

<div class="row">
    <partial name="ParentTutorCountByLocation" />
</div>

it is load the partial but without data not sure how i can do it. (can't use viewcomponents and ajax)

Anduin Xue
  • 3,266
  • 2
  • 22
  • 43
Ram Singh
  • 6,664
  • 35
  • 100
  • 166
  • Why not pass a `model` explictly e.g. ``? – itminus Feb 11 '20 at 07:11
  • _“can't use viewcomponents”_ – *Why*? That’s exactly what view components are for. Partials cannot run their own logic in a controller-like action. – poke Feb 11 '20 at 08:49

1 Answers1

0

You need to use something like Html.Action to render partial view from the controller. Unfortunately, ASP.NET Core doesn't support this out of the box. You can find Html.Action implementation here

Once you implement, you can do something like this.

@Html.Action("YourPartialView")
Anuraj
  • 18,859
  • 7
  • 53
  • 79