您可以做很多事情。如前所述,第一级是使用不同的 CSS 文件。您可以通过创建 Helper 方法动态地将不同的路径放入您的 CSS 文件。所以它会像这样使用:
<link href="<%=AppHelper.GetCSSPath("mysite.css")%>" rel="stylesheet" type="text/css" />
这为您提供了一定程度的自定义。更深一层实际上是每个子站点都有不同的视图文件。您可以通过创建一个新的 ViewEngine 来做到这一点:
public class SubSiteViewEngine: WebFormViewEngine
{
private string GetSiteRoot() {
// some logic to get the site root from the incoming URL
}
public SubSiteViewEngine()
{
MasterLocationFormats = new[] {
GetSiteRoote() + "/Views/{1}/{0}.master",
GetSiteRoote() + "/Views/Shared/{0}.master" ,
GetSiteRoote() + "/Views/Shared/MasterViews/{0}.master"
};
ViewLocationFormats = new[] {
GetSiteRoote() + "/Views/{1}/{0}.aspx",
GetSiteRoote() + "/Views/{1}/{0}.ascx",
GetSiteRoote() + "/Views/Shared/{0}.aspx",
GetSiteRoote() + "/Views/Shared/{0}.ascx",
GetSiteRoote() + "/Views/Shared/Controls/{0}.ascx"
};
PartialViewLocationFormats = ViewLocationFormats;
}
}
希望对您有所帮助。
附:我很快就会为我自己的项目做这件事,所以我应该很快就会有一些实际的工作代码。