I'm trying to get the URL of a published binary via the BinaryFactory of DD4T:

// Attempt to resolve as binary link
IBinary binary;
if (this.BinaryFactory.TryGetBinary(componentUri, out binary))
    // Binary link resolves; use the URL property of the binary object
    targetUrl = binary.Url;

Unfortunately even if the binary is resolved the Url property is always null (as are other properties of the binary except the BinaryData property which is containing the data).

Any idea how I can get the URL of the published binary through DD4T?


1 Answer 1


Bart pointed me in the right direction; TryGetBinary does indeed not populate the Url property but it does load the contents of the binary from the broker which is not what I would want when resolving links anyway.

Fortunately the source reveals the GetUrlForUri() method which does exactly what I need:

// Attempt to resolve as binary link
targetUrl = this.BinaryFactory.GetUrlForUri(componentUri);

instead of my original code works as intended.

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.