How to get full URL of particular document

This article shows how to get full URL of the document.
To do so, you can try e.g. to get node according to document´s GUID, culture code and site name. Document GUID number (Node GUID) can be found in CMSDesk -> Content -> select document -> Properties -> General, or in database.

First, you need to create new node using:

CMS.TreeEngine.TreeProvider tp = new CMS.TreeEngine.TreeProvider();
TreeNode tn = tp.SelectSingleNode(Guid, CultureCode, SiteName);

Then you can use UrlHelper.ResolveUrl('~' + tn.AliasPath);, which returns string with relative path. Then you can use this string as parameter in this method: UrlHelper.GetAbsoluteUrl(String relative URL) which returns an absolute path as you need.

UPDATE for Kentico version 6:
// for example /Home
string aliasPath = CMSContext.CurrentDocument.NodeAliasPath;
string fullURL = URLHelper.GetAbsoluteUrl(URLHelper.ResolveUrl("~" + aliasPath + ".aspx"));

See also:

Applies to: Kentico CMS 4.x, 5.x, 6.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.