Get the Url of a Sitefinity Page from the Guid

By in
No comments

If you are working with the Sitefinity Pages API you can easily retrieve the Id of any page in the system. You might also be working with a custom or intra-site module, which has a static Guid property for the landing page.

The Page object itself only has a UrlName property, which returns only the part of the url for that particular page itself, with no relation to where it actually is in the Sitemap.

Fortunately, there is an extension method in the Telerik.Sitefinity.Modules.Pages that can return the actual full url to the page.

The following snippet demonstrates how you can pass in a Guid and get the full url to the page.

public string GetPageUrl(Guid PageID)
{
	var mgr = PageManager.GetManager();
	var pageNode = mgr.GetPageNode(PageID);
	return pageNode.GetFullUrl();
}

View Code Snippet on Gist

Be sure to include the namespace above in your class file.

The following two tabs change content below.

selaromdotnet

Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.