我有一个像这样调用的视图组件:
@{
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
,使其只是一些文本,而没有其他内容,因此不会出现内部页面错误。删除参数/模型,同样的事情。它只是没有返回任何东西。
我该怎么办?
右键单击控制器中的 InvokeAsync 并从那里创建一个它将起作用的视图