我无法使用生成 url
string.Format("/sitecore/shell/Applications/Content%20Manager/default.aspx?id={0}&la={1}&fo={0}",contentItem.ID, contentItem.Language)
这会生成类似于项目路径的内容,但不会生成重定向到内容的实际 url。我是否缺少任何设置?我真的很感激任何帮助。
谢谢。
我无法使用生成 url
string.Format("/sitecore/shell/Applications/Content%20Manager/default.aspx?id={0}&la={1}&fo={0}",contentItem.ID, contentItem.Language)
这会生成类似于项目路径的内容,但不会生成重定向到内容的实际 url。我是否缺少任何设置?我真的很感激任何帮助。
谢谢。
如果它是您想要 URL 的媒体项目
Database master = Sitecore.Configuration.Factory.GetDatabase ("master");
Item item = master.GetItem ("/sitecore/media library/Images/XXX");
If (item! = null)
{
MediaItem mediaItem = new MediaItem (item);
img.ImageUrl = Sitecore.Resources.Media.MediaManager.GetMediaUrl (mediaItem);
}
如果它是一个内容项,您可以简单地附加路径,例如 http://{yoursite}/{path relative to home item}
我不明白你到底想要达到什么目的。但是,如果您想要一个项目的 URL,那么我认为您可以使用以下内容:
Sitecore.Links.LinkManager.GetItemUrl(item);
除了 Mark 提供的答案之外,您还可以尝试以下方法来获取包含域的完整服务器 URL:
UrlOptions urlOptions = new UrlOptions();
urlOptions.AlwaysIncludeServerUrl = true;
LinkManager.GetItemUrl(item, urlOptions);