我在项目中添加了一个名为/Areas/Views/Shared 的区域(仅供参考...这是对视图/共享默认值的补充(
我相信我已将其正确添加到启动中的服务中(在服务之后添加。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
我读了几篇帖子,例如下面的项目...但我暂时被困住了
使用自定义位置时 asp.net 如何在核心 mvc 中指定视图位置?
经过一番玩法,我找到了解决方案......我错过了{0}
Startup.cs
services.Configure<RazorViewEngineOptions>(options => options.ViewLocationFormats.Add("/Areas/Views/Shared/{0}" + RazorViewEngine.ViewExtension));