/// <summary> /// A site was provisioned. /// </summary> public override void WebProvisioned(SPWebEventProperties properties) { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; SPSecurity.RunWithElevatedPrivileges(delegate() { try { base.WebProvisioned(properties); var rootWeb = properties.Web.Site.RootWeb; var currentWeb = properties.Web; var siteCollection = currentWeb.Site; using (currentWeb) { var webAppRelativePath = BrandingHelper.WebAppPath(currentWeb, siteCollection); BrandingHelper.InheritTopSiteBranding(currentWeb, rootWeb, siteCollection, webAppRelativePath); } } catch (Exception ex) { diagSvc.WriteTrace(0, new SPDiagnosticsCategory("Error Info", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "Houston, we have a problem in WebProvisioned event: {0}---{1}", ex.InnerException, ex.StackTrace); } }); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { var currentWeb = properties.Feature.Parent as SPWeb; var siteCollection = currentWeb.Site; var rootWeb = currentWeb.Site.RootWeb; var webAppRelativePath = BrandingHelper.WebAppPath(currentWeb, siteCollection); BrandingHelper.InheritTopSiteBranding(currentWeb, rootWeb, siteCollection, webAppRelativePath); }