RCL 代表 Razor 类库。
我使用共享文件 _Layout.cshtml 制作了自己的原型 RCL,我想将它包含在我的项目中。我已经从 NuGet 安装了 RCL,希望它能自动工作,但显然不能。
我删除了我的 _Layout.cshtml,希望它会从我制作的 RCL 中获取,但显然这不会像那样工作。我收到以下错误:
An unhandled exception occurred while processing the request.
InvalidOperationException: The layout view '_Layout' could not be located. The following locations were searched:
/Pages/_Layout.cshtml
/Pages/Shared/_Layout.cshtml
/Views/Shared/_Layout.cshtml
Microsoft.AspNetCore.Mvc.Razor.RazorView.GetLayoutPage(ViewContext context, string executingFilePath, string layoutPath)
- 如何正确将此 RCL 导入我的新 Web 应用程序?
更新
我添加@using libnamehere
到我的 _ViewImports.cshtml 文件中并注释掉了其中唯一的代码行,_ViewStart.cshtml
但现在我收到以下错误:
InvalidOperationException: RenderBody has not been called for the page at '/Pages/Shared/_Layout.cshtml'. To ignore call IgnoreBody().
Microsoft.AspNetCore.Mvc.Razor.RazorPage.EnsureRenderedBodyOrSections()