3

When I read a component's WebDavUrl via PageData using the Core Service its returning "null"?

var page = (PageData)client.Read("tcm:71-122971-64", new ReadOptions());                
Console.WriteLine(page.ComponentPresentations[0].Component.WebDavUrl);

Is there a different way to get to the WebDavUrl?

1 Answer 1

6

WebDavUrls of linked items are not read unless you are reading it with correct LoadFlags, like:

var page = (PageData)client.Read("tcm:71-122971-64", new ReadOptions{LoadFlags = LoadFlags.WebDavUrls});  
5
  • Just spotted that when you answered! Gotta wait 10 minutes before I can accept though!
    – Neil
    Commented Apr 28, 2014 at 9:11
  • Intrigued - what's wrong with the use of "as" when casting then Dominic?
    – Neil
    Commented Apr 28, 2014 at 13:26
  • 1
    To me, a cast is always preferred over using the as keyword, since the latter will not throw an exception when the cast is invalid. But if you will always check if your object returned is not null, then you can just as well use the as keyword. Commented Apr 28, 2014 at 13:32
  • 1
  • I see Bart and David have already provided good input. For the full discussion - rants and all... see meta.tridion.stackexchange.com/q/168/129 :-) Commented Apr 29, 2014 at 7:21

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.