Getting the URL to the Content Type Hub Programmatically in SharePoint 2010

Posted by Damon on Simple Talk See other posts from Simple Talk or by Damon
Published on Tue, 07 Feb 2012 17:23:38 GMT Indexed on 2012/03/18 18:16 UTC
Read the original article Hit count: 274

Many organizations use the content-type hub to manage content-types in their SharePoint 2010 environment.  As a developer in these types of organizations, you may one day find yourself in need of getting the URL of the content type hub programmatically.  Here is a quick snippet that demonstrates how to do it fairly painlessly:

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

© Simple Talk or respective owner

Related posts about .NET Development

Related posts about sharepoint