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

Comments 0

Share to social media

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;
}

Load comments

About the author

Damon Armstrong

See Profile

Damon Armstrong is a consultant with SystemwarePS in Dallas, Texas. He is also a blogger and author of Pro ASP.NET 2.0 Website Programming and SharePoint 2013 Essentials for Developers. He specializes in the Microsoft stack with a focus on web technologies like MVC, ASP.NET, JavaScript, and SharePoint. When not staying up all night coding, he can be found watching a bunch of kids, studying Biblical topics, playing golf, or recovering from staying up all night coding.