桌面应用程序中的.NET Core MVC视图组件:Component.InvokeAsync找不到视图

时间:2019-06-11 13:35:00

标签: c# asp.net-core razor .net-core view-components

我已经在.NET Core中建立了一个网站,并且工作正常。

现在,我要按照here的说明在Windows Chromium桌面应用程序内启动.NET Core Web App:我运行app MyMvcApp.dll

应用程序启动,但尝试为视图组件( ProgressViewComponent )加载视图,并引发错误: InvalidOperationException:未找到视图'Components / Progress / Default' 。搜索了以下位置: /Views/RawDataFileCopy/Components/Progress/Default.cshtml /Views/Shared/Components/Progress/Default.cshtml /Pages/Shared/Components/Progress/Default.cshtml

失败的行:

@await Component.InvokeAsync("Progress", new { processId = Model.ProcessId, processName = Model.ProcessName })

在Visual Studio中,在我的ASP.NET Core项目中,我的文件位于 Views / Shared / Components / Progress / Default.cshtml 中,并且在运行Web应用程序时可以正常工作在浏览器中。

有趣的是,我注意到编译器创建了 MyMvcApp.Views.dll ,但是如果我对其进行反编译,则实际上看不到 Progress / Default 视图,所以也许问题在于它没有正确地编译视图。

任何想法都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

未将视图上的构建操作设置为 Content 。我将其更改为 Content ,并且有效。