ASP.NET Core 视图组件返回空白页面

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

我有一个像这样调用的视图组件:

@{
    await Component.InvokeAsync("Edit", new { config = new List<EditConfiguration>() });
}

看起来像这样:

// Need to make individual view components for every page
public class EditViewComponent : ViewComponent
{
    public async Task<IViewComponentResult> InvokeAsync(List<EditConfiguration> config)
    {
        return View("~/Views/Edit/Edit.cshtml", config);
    }
}

我已经通过断点确认代码正在输入

InvokeAsync
方法和
Edit.cshtml

但是

InvokeAsync
实际上没有返回任何内容,页面只是空白。即使我只是更改
Edit.cshtml
,使其只是一些文本,而没有其他内容,因此不会出现内部页面错误。删除参数/模型,同样的事情。它只是没有返回任何东西。

我该怎么办?

c# asp.net-core asp.net-core-mvc asp.net-core-viewcomponent
1个回答
0
投票

右键单击控制器中的 InvokeAsync 并从那里创建一个它将起作用的视图

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