Here is my code on feature activated:-
SPWeb topLevelSite = properties.Feature.Parent as SPWeb;
if (topLevelSite != null)
{
// Calculate relative path to site from Web Application root.
string WebAppRelativePath = topLevelSite.ServerRelativeUrl;
if (!WebAppRelativePath.EndsWith("/"))
{
WebAppRelativePath += "/";
}
// Enumerate through each site and apply branding.
topLevelSite.MasterUrl = WebAppRelativePath +
"_catalogs/masterpage/InternalM1.master";
topLevelSite.CustomMasterUrl = WebAppRelativePath +
"_catalogs/masterpage/InternalM1.master";
topLevelSite.Update();
}
The scope of feature if set to 'WEB' then masterpage gets applied to the site. However, I want to set the scope to SITE COLLECTION ('SITE') so that all the subsites belonging to that site collection inherit the masterpage. If I do this then the masterpage doesn't get applied.
Am I doing any mistake?