我的文件结构可能会以一种我们不确切知道视图位置的方式发展。
这是一个例子:
添加ViewLocationExpander
中的每个选项变得难以阅读并且难以快速维护。
public class CustomViewLocationExpander: IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
return new[] {
"~/UI/{1}/{0}.cshtml",
"~/UI/Shared/{0}.cshtml",
"~/UI/Home/App/{1}/{0}.cshtml",
"~/UI/Home/App/Another/{1}/{0}.cshtml",
"~/UI/Admin/App/{1}/{0}.cshtml",
"~/UI/Admin/App/Another/{1}/{0}.cshtml"
// ...
};
}
public void PopulateValues(ViewLocationExpanderContext context) { }
}
是否有以安全方式添加目录下的每个视图的语法?
比如"~UI/**/{1}/{0}.cshtml"
?