DavidGreenberg
Crownpeak Employee
Crownpeak Employee

Get Last Published Link

There are times where you may want to get the last published link instead of running the publish link again. However you also want to get the link if the asset has yet to be published.

 

This code will perform that function

 

public static string GetPublishedLink(Asset asset, OutputContext context = null, bool addDomain = false, ProtocolType protocolType = ProtocolType.Https, bool useLastCachedLink = false)
{
string outputLink = "";
if (asset.IsLoaded)
{
List<string> assetlinks = asset.GetLastPublishedLinks(addDomain, protocolType);
if (assetlinks.Count > 0)
{
if (useLastCachedLink)
{
outputLink = assetlinks[assetlinks.Count - 1];
}
else
{
outputLink = assetlinks[0];
} }
else
{
outputLink = asset.GetLink(addDomain, protocolType);
}
} return outputLink;
}
Labels (1)

Can't find what you are looking for?

Find Answers

Search our DXM Forum to find answers to questions asked by other DXM users.

Ask a Question

No luck? Ask a question. Our Product and Support teams are monitoring the Forum and typically respond within 48 hours.

Ask a Question