Using the Core Service, how do I get a page or tcm id for a page when all I have is the live site url where the page is hosted?


If I .Get(uri) a page by it's Tcm Id, the page object has LocationInfo.PublishLocationUrl = "/FolderA/FolderB/pageC.html", so I know the data supports a lookup. But there doesn't seem to be a way to filter for the LocationInfo.PublishLocationUrl.

Here's how I'm getting pages, but there doesn't appear to be a way to filter for LocationInfo.

        var filter = new OrganizationalItemItemsFilterData();
        filter.ItemTypes = new[] { ItemType.Page };
        var pages = this.Client.GetList(rootStructureGroupId, filter);

filter.BaseColumns = ListBaseColumns.Extended; doesn't seem include any LocationInfo either.

I ended up coming up with a way to break the live site url into segments "FolderA", "FolderB", "pageC.html" and recursively grabbing all structure groups under structure groups until grabbing all pages in the final structure group and then selecting the page with the matching PublicationLocationUrl.

The problem with this approach is it's very expensive and takes too long. Grabbing child structure groups or pages via .GetList(uri) only get partially hydrated and do not include LocationInfo. I have to do a Get(uri) against every object to get the fully hydrated object. It's taking a few seconds to do a look up for one url. When processes a document that contains 20 some odd urls, it takes minutes to run this logic. I figure there's got to be a better way.

2 Answers 2


In CoreService you can get items either by TCMID or WebDavURL.

Assuming (big assumption, but from how you are retrieving it now could be accurate) your published directory and page structure naming exactly matches your Tridion tree counterparts, you could massage the live URL into a WebDavURL and open the item using that.

CoreService.Read(WebDavUrl, new ReadOptions {LoadFlags = LoadFlags.Expanded});

If all you have is a live site url, I wonder if you should be using the Core Service at all. A live site url seems to indicate me you are on the Presentation Server or Delivery side. The Core Service belongs to the Content Manager side, and you should usually not need to (or want to) use the Core Service from your Delivery side.

If you are indeed looking for an approach to access data on the Delivery side, you will probabaly want to investigate the Content Delivery API, and retrieve the data you need from the Broker. Since what is in the Brker is published data, and accessing the CM data through the Core Service on the delivery side, will potentially give you access to unpublished data, so invalid in the context.

If you are talking about some integration on the CM side, then the Core Service is indeed a correct approach, and then I think your only option is indeed to transform the live site URL into a WebDAV URL as Chris suggests. Not optimal, but perhaps you should look at where you get the live site url from, and see if it might be better to store additional info like a URI or WebDAV URL there.

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.