I load features using the code bellow:

string siteUrl = "http://MyServer/sites/MySiteCollection";

ClientContext clientContext = new ClientContext(siteUrl);
Web site = clientContext.Web;
FeatureCollection collFeature = site.Features;


But I also need a scope of each feature. I mean value of FeatureDefinitionScope type. Do you know how load this value via csom ?


With your code, you will only retrieve all features with scope "Web". There is actually a difference between features scoped to a site ("Web" class) or to a site collection ("Site" class).

The following adjusted code retrieves all active features for the site collection and the site:

string siteUrl = "http://MyServer/sites/MySiteCollection";

ClientContext clientContext = new ClientContext(siteUrl);
Site siteCollection = clientContext.Site;
Web site = clientContext.Web;

FeatureCollection siteCollectionFeatures = siteCollection.Features;
FeatureCollection siteFeatures = site.Features;


I'm certain that you won't be able to access WebApplication and Farm features with CSOM (SharePoint client-side object model). As you want to support SharePoint Online, that's your barrier.

If you only want to go for SharePoint OnPremise (SharePoint Foundation or Server), you could go for SSOM (SharePoint server-side object model), which Jerry_MSFT described above. WebApplication features could then be accessed using web.Site.WebApplication.Features (web is your SPWeb class). But you don't have that possibility in CSOM.

  • Yes. thanks. But what about the other features - Farm ? – isxaker Nov 26 '18 at 13:01
  • See my addition to the post above. I'm sure that you won't be able to achieve that using CSOM. – Anon Nov 26 '18 at 15:44
  • and moreover there're WebApp Features also – isxaker Nov 26 '18 at 20:25

In CSOM Feature Object, there is no "FeatureDefinitionScope", please check the documentation:

enter image description here

Feature properties

If you are using SharePoint On-Premise Environment, you can use the Server Object Model below to get this property:

   SPSite site = new SPSite("http://sp/sites/dev/");
    SPWeb web = site.OpenWeb();
    foreach (SPFeature feature in site.Features)

enter image description here

  • Nice, thank you very much. But of course I've already checked the official documentation for many times and have not found it. And unfortunately I can't use server object model. So this answer is an answer for kinda different question. I need csom. But anyway thanks. – isxaker Nov 23 '18 at 9:08
  • @isxaker, what's your SharePoint version, Online or On-Premise ? – Jerry_MSFT Nov 26 '18 at 0:36
  • I need a solution for both type of SP. – isxaker Nov 26 '18 at 8:00

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.