SharePoint Difference Between SPWeb.AvailableContentTypes Vs SPWeb.ContentTypes

We are using SPWeb.AvailableContentTypes and SPWeb.ContentTypes to get content types from SharePoint.

I was facing an issue regarding content types that some content types are not available from code because I was using AvailableContentTypes from sub site and after some research I found difference between SPWeb.AvailableContentTypes and SPWeb.ContentTypes
SPWeb.ContentTypes :
The ContentTypes property returns only the content types that exist on the current Web site, not all content types in the current scope.

Use the AvailableContentTypes property to return all content types in the current scope, including those of any parent Web sites.
static void GetContentTypes()
using (SPSite oSite = new SPSite(@”http://dell-pc:9999/”))
using (SPWeb oWeb = oSite.OpenWeb())
//SPContentTypeCollection ctypecoll = oWeb.ContentTypes; // USING CONTENT TYPES
SPContentTypeCollection ctypecoll = oWeb.AvailableContentTypes; // USING AVAILABLE CONTENT TYPES
foreach (SPContentType type in ctypecoll)
Console.WriteLine(“ID: ” + type.Id + ” ; Name: ” + type.Name);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s