How to get full URL of particular document

编程入门 行业动态 更新时间:2024-10-10 14:23:45

原帖地址: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"));


更多推荐

How to get full URL of particular document

本文发布于:2023-06-13 21:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:full   URL   document

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!