1
我已创建了作为功能部署的自定义主页面。我正在使用SP Foundation而不是SP Server。将自定义主页面应用于所有SP基金会网站
我已经激活了该功能,但masterpage只应用于顶级网站。有人可以让我知道我的事件接收器做了什么问题。
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite siteCollection = properties.Feature.Parent as SPSite;
if (siteCollection != null)
{
SPWeb topLevelSite = siteCollection.RootWeb;
// Calculate relative path to site from Web Application root.
string WebAppRelativePath = topLevelSite.ServerRelativeUrl;
if (!WebAppRelativePath.EndsWith("/"))
{
WebAppRelativePath += "/";
}
// Enumerate through each site and apply branding.
foreach (SPWeb site in siteCollection.AllWebs)
{
site.MasterUrl = WebAppRelativePath + "_catalogs/masterpage/custom.master";
site.CustomMasterUrl = WebAppRelativePath + "_catalogs/masterpage/custom.master";
site.Update();
}
}
}
任何帮助将是伟大的!