SoftLinks and getting links to Blocks


I'm trying to create a 'cross-reference' for a page where I show any content referenced by the page (pages, blocks, media and external links), and also any content referencing the page.

For content referenced by the page, I can use the following method to retrieve soft links:

IList slc = ServiceLocator.Current.GetInstance().Load()

Then for each SoftLink in the collection, I can obtain a link to the referenced content for blocks and pages as follows (sl is an instance of SoftLink) (UrlResolver.Current.GetUrl(sl.ReferencedContentLink) always returns null for blocks, but works for media and pages):

            UrlResolver instance = ServiceLocator.Current.GetInstance();
            var urlB = new UrlBuilder(sl.Url);
            string contentUrl = instance.GetUrl(urlB, ContextMode.Edit);

However, when I get referencing softlinks by using the following method:

IList slc = ServiceLocator.Current.GetInstance().Load(true)

The SoftLink's Url property now points to the current page which is correct as this is now the 'source' of the softlink, but now I can't get the URL for blocks, as UrlResolver.Current.GetUrl doesn't work for block content references.

So is there a way to get a URL to a block, just knowing its content reference?

Nov 18, 2014 12:08

Hi Mark,

Did you find a solution to this? I'm interested in getting a URL to a block as well.


Dec 22, 2014 12:09

One key characteristic of blocks is that they have no public URL (that is a key difference between pages and blocks) meaning they can not be rendered on its own, instead are they rendered as parts of other content e.g. when used in a contentarea.

You can however get a preview or edit url to a block, in that case is the block rendered in the preview template.

The url can be retrieved from

UrlResolver.Current.GetUrl(blockLink, null, new VirtualPathArguments { ContextMode = ContextMode.Preview });

Dec 23, 2014 14:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.