Search code examples
c#sharepointsharepoint-2013sharepoint-object-model

How to get all of the deactivated Features in the farm that could be activated for the specific web using Sharepoint Server Object Model?


I need to get list of SPFeatureDefinitions like in ManageFeatures.aspx page. Probably it should be smth like this:

...
using (SPWeb web = spSite.OpenWeb())
foreach (var spfeature in SPFarm.Local.FeatureDefinitions)
{
    result.Add(spfeature);                           
}

But how can I be sure that spfeature could be activated on web?


Solution

  • try using if (spfeature.Scope = SPFeatureScope.Web)