Telerik Sitefinity- Retrieving a page by it’s URL or GUID- or finding a page’s GUID from its URL!


I recently started work at my new job, and here we use Telerik Sitefinity as the CMS for some websites.  I was recently tasked with writing some code which involved supplying the end url for a page, and then matching this against the corresponding record in the CMS- after much searching I found nothing and eventually got a response from their support so figured i would blog it!

var url = "~/test2.aspx";

var Manager = new CmsManager();
int totalRows;
List conditions = new List();
CmsSiteMapNode node = (CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode(url);

// here is the GUID for the page
var pageId = new Guid(node.Key);

conditions.Add(new CmsQueryCondition("ID", Nolics.ORMapper.Base.QueryCondition.EQ, pageId));
// and here is the page
var result = Manager.GetPages(0, 0, string.Empty, System.ComponentModel.ListSortDirection.Descending, conditions, out totalRows);
  1. No comments yet.
(will not be published)