Iam deploying solution to site scoped feature , and in feature activated event receiver iam writing the code to activate feature to all subsites but error is "feature is site-scoped and cannot be added to the web sharepoint 2010 " and code is

using (SPSite osite = properties.Feature.Parent as SPSite)
                        Guid featureGuid = new Guid(xxxxxxxxxxxxx);
                        foreach (SPWeb webs in osite.AllWebs)


Site features (here site means "site collection", while web means root-site/sub-site) can only be activated at a site-collection level (i.e. from the root-site of a collection, under the "Site collection features" page).
Site features produce their effects on the entire site collection. For instance:

  • If it contains a custom action, the custom action is visible in all sub-sites.
  • If it contains a Web part, the Web part is provisioned in the site collection Web part galery (located at the root-level) and is then available for all sites in the collection.

Some artifacts cannot be scoped site (see list at msdn).

So, either your feature is site scoped, or it's web scoped. There's no point at all in trying to activate a site feature at a web level. And it's not your responsibility to activate a site feature on all sub-sites: intrinsically, the site feature impacts all sites (webs) of the collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.