Get All Content Types From Site in SharePoint using CSOM

The example in this topic show how to use CSOM to Get All Content Types From Site in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext ("http://MyServer/sites/MySiteCollection"))
  • {
  • ContentTypeCollection oContentTypeCollection = clientcontext.Web.ContentTypes;
  •  
  • // Here Content Type Collection loaded including Content Type Name
  • clientcontext.Load(oContentTypeCollection, Collection => Collection.Include(ContentType => ContentType.Name));
  •  
  • clientcontext.ExecuteQuery();
  •  
  • foreach (ContentType oContentType in oContentTypeCollection)
  • {
  • Console.WriteLine("Conent Type Name: " + oContentType.Name);
  • }
  • }

Thank you for reading this article. This code was tested in SharePoint 2013


© 2019 Code SharePoint