【发布时间】:2018-03-12 16:34:49
【问题描述】:
我在我的项目中添加了一个名为 /Areas/Views/Shared 的区域 (仅供参考...这是对 Views/Shared 默认值的补充)
我相信我在 Startup 中将其正确添加到服务中(在 services.AddMvc 之后添加)
Startup.cs
services.Configure<RazorViewEngineOptions>(options => options.ViewLocationFormats.Add("/Areas/Views/Shared/" + RazorViewEngine.ViewExtension));
我收到以下错误:
InvalidOperationException: The partial view 'Areas/Views/Shared/_foo' was not found.
The following locations were searched:
/Views/Shared/_foo.cshtml
如果 _foo.cshtml 不存在,那么我希望异常如下所示:
InvalidOperationException: The partial view 'Areas/Views/Shared/_foo' was not found.
The following locations were searched:
/Views/Shared/_foo.cshtml
/Areas/Views/Shared/_foo.cshtml
我阅读了一些帖子,例如下面的项目......但我暂时被卡住了
How to specify the view location in asp.net core mvc when using custom locations?
【问题讨论】:
标签: asp.net-core-2.0