sitecore

LinkManager

Syntax#

  • public static string GetItemUrl(Item item)
  • public static string GetItemUrl(Item item, UrlOptions options);

Obtaining a url for an Item

Given a simple sitecore item:

Item item;

The item itself does not contain it’s url. To obtain a url for an item you need to make a call to the static class Sitecore.Links.LinkManager

string url = LinkManager.GetItemUrl(item);

an overload of this accepts a UrlOptions class:

UrlOptions options = new UrlOptions
{
     AddAspxExtension = false
     ....
};
string url = LinkManager.GetItemUrl(item, options);

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow