我在web.config中设置了一个主题,这意味着每个客户都可以为同一webshop加载不同的视图。
在Application_Start中,我有:
RazorViewEngine viewEngine = new RazorViewEngine();
var theme = System.Configuration.ConfigurationManager.AppSettings["Themes"];
viewEngine.PartialViewLocationFormats =
viewEngine.ViewLocationFormats =
viewEngine.MasterLocationFormats =
new string[] {
"~/Assets/Views/{1}/{0}.cshtml",
"~/Assets/Views/Shared/{1}/{0}.cshtml"};
viewEngine.AreaMasterLocationFormats =
viewEngine.AreaPartialViewLocationFormats =
viewEngine.AreaViewLocationFormats =
new string[] {
"~/Assets/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Assets/Areas/{2}/Views/Shared/{1}/{0}.cshtml"};
ViewEngines.Engines.Add(viewEngine);
这行得通,但是如果找不到视图文件,该如何定义后备?