admin管理员组

文章数量:1571365

原帖地址:http://devnet.kentico/Knowledge-Base/API-and-Internals/How-to-get-full-URL-of-particular-document.aspx


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"));


本文标签: fullurlDocument