在 Controllers 文件夹中,我创建了一个“Profile”子文件夹(/Controllers/Profile),并且我使用下面的代码将 /Views/Profile/{controller}/{action} 添加到 View Location Formats。
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationFormats.Add("/Views/Profile/{1}/{0}" + RazorViewEngine.ViewExtension);
});
现在我想对所有配置文件页面使用相同的布局,并且我希望它是 /Views/Profile/_layout.cshtml,但除非我将它放在特定的控制器文件夹中,否则它不会被识别。
在检查 /Views/Shared 之前,有什么方法可以让每个视图在其父目录中查找 _layout?