如何从asp.net核心中的控制器渲染局部视图

问题描述 投票:0回答:1

我在控制器中有如下操作,为Partial view加载数据:

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

我必须通过另一个视图调用它:

tried,renderPartialAsync,Partial

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

这是部分加载,但没有数据不确定我怎么做。 (不能使用viewcomponents和ajax)

asp.net-core partial-views
1个回答
0
投票

您需要使用Html.Action之类的东西来渲染控制器的部分视图。不幸的是,ASP.NET Core不支持此功能。您可以找到Html.Action实现here

© www.soinside.com 2019 - 2024. All rights reserved.