如果将项目拆分为 4 个 web 项目的原因是客户有不同的观点,请尝试以下操作:
有 1 个 webproject 并为不同的视图使用子文件夹。
- Views/Home/About.aspx(如果没有找到匹配的子文件夹,则使用)
- Views/Home/Customer1/About.aspx
- Views/Home/Customer2/About.aspx
您可以有一个自定义视图引擎来决定它应该呈现哪个视图。Web 的每个安装都在 web.config 中定义了一个客户。
public class MultiTennantWebFormViewEngine : WebFormViewEngine
{
private static string[] LocalViewFormats =
new string[] {
"~/Views/{1}/" + ApplicationConfiguration.CustomerName + "/{0}.aspx",
"~/Views/{1}/{0}.aspx",
"~/Views/{1}/" + ApplicationConfiguration.CustomerName + "/{0}.ascx",
"~/Views/{1}/{0}.ascx",
"~/Views/Shared/{0}.aspx",
"~/Views/Shared/{0}.ascx"
};
public LocalizationWebFormViewEngine()
{
base.ViewLocationFormats = LocalViewFormats;
base.PartialViewLocationFormats = LocalViewFormats;
base.MasterLocationFormats = new string[] {
"~/Views/{1}/" + ApplicationConfiguration.CustomerName + "/{0}.master",
"~/Views/{1}/{0}.master",
"~/Views/Shared/" + ApplicationConfiguration.CustomerName + "/{0}.master",
"~/Views/Shared/{0}.master"
};
}
}