Home > SharePoint, SharePoint 2010 > SharePoint 2010: How to get the Content Type Hub URL Programmatically

SharePoint 2010: How to get the Content Type Hub URL Programmatically


If you are using a Content Type Hub, and you have code that needs to know the URL of the Content Type Hub, you can get this programmatically as shown below.

This involves opening a TaxonomySession where you can find the URL through the ContentTypePublishingHub property of the DefaultSitecollectionTermStore.

public Uri GetContentTypeHubUrl(SPSite site) 
{ 
TaxonomySession session = new TaxonomySession(site); 
return session.DefaultSiteCollectionTermStore.ContentTypePublishingHub; 
}

This is something I came across in Damon Armstrong’s blog a long time back but never got around to writing about it before.

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this: