更新时间:2023-02-20 18:37:17
如此答案:
在.Net-Core v2.0或更高版本中,您可以使用 ViewLocationFormats 和 AreaViewLocationFormats
来修改视图查找。
From .Net-Core v2.0 upwards you can use ViewLocationFormats
and AreaViewLocationFormats
in RazorViewEngineOptions to modify the View look-up.
您正在寻找的选项是 ViewLocationFormats
,因为您没有使用查看区域。
The option you are looking for is ViewLocationFormats
since you're not using View Areas.
您的解决方案将不断发展这些行:
Your Solution would be along these lines:
services.Configure<RazorViewEngineOptions>(o =>
{
o.ViewLocationFormats.Clear();
o.ViewLocationFormats.Add("/MVC/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
o.ViewLocationFormats.Add("/MVC/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
});
仅当您在该位置而不是在标准文件夹。
The last line is only needed if you have the shared Layouts and Paritals at that location and not in the Standard Folder.