如果将项目拆分为4个WebProject的原因是客户有不同的观点,请尝试以下方法:
拥有1个webproject,并对不同的视图使用子文件夹。
-
Views/Home/About.aspx(在未找到匹配的子文件夹时使用)
-
Views/Home/Customer1/About.aspx
-
Views/Home/Customer2/About.aspx
您可以使用自定义的viewengine来决定应该渲染哪个视图。每个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"
};
}
}