6

How to get master page gallery via CSOM so that we would support language packs / we cannot use Lists.GetByTitle("Master Page Gallery").

So how to get list "_catalogs/masterpage"?

1 Answer 1

8

How to get Master Page gallery via Managed CSOM

Use Site.GetCatalog method with ListTemplateType.MasterPageCatalog to retrieve Master Page gallery:

var list = context.Site.GetCatalog((int)ListTemplateType.MasterPageCatalog);
context.Load(list);
context.ExecuteQuery();
Console.WriteLine(list.Title);

Note: SharePoint 2010 & 2013 compatible

3
  • 1
    Nice, didn't know about that method (deleted my answer)
    – eirikb
    Commented Apr 17, 2014 at 9:43
  • 3
    And then of course /_api/Web/GetCatalog(116) will work as well
    – eirikb
    Commented Apr 17, 2014 at 9:45
  • 1
    Good.. We could also use Web.GetCatalog for non-publishing and Site.GetCatalog for publishing site collections etc.
    – thomius
    Commented Apr 17, 2014 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.