Query full page URL

In this article, you learn how to query the full URL of a page. The overall algorithm is to use the GetSiteBySiteMapRoot method to get the site to which the page belongs. Then, you use the UrlLocalizationService to resolve the language-specific URL of the page and use some string manipulation to construct the full URL.

If you are using  PageNode to represent your page objects, follow this sample: ```C# using System.Globalization; using Telerik.Sitefinity.Abstractions; using Telerik.Sitefinity.Localization.UrlLocalizationStrategies; using Telerik.Sitefinity.Modules.Pages; using Telerik.Sitefinity.Multisite; using Telerik.Sitefinity.Pages.Model; using Telerik.Sitefinity.Services;

namespace SitefinityWebApp { public partial class RetrieveFullPageURLExample { public string RetrievePageAbsoluteURL(PageNode pageNode, CultureInfo culture) { string url = string.Empty; MultisiteContext multisiteContext = SystemManager.CurrentContext as MultisiteContext; UrlLocalizationService s = ObjectFactory.Resolve();

        ISite site = multisiteContext.GetSiteBySiteMapRoot(pageNode.RootNodeId);

        if (site != null)
        {
            string domain = (site.RequiresSsl ? "https://" : "http://") + site.LiveUrl;
            url = domain + s.ResolveUrl(pageNode.GetUrl(culture), culture).Trim('~');
        }

        return url;
    }
}

}


If you are using PageSiteNode to represent your page objects, follow this sample: ```C#
using System;
using System.Globalization;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Localization.UrlLocalizationStrategies;
using Telerik.Sitefinity.Multisite;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web;

namespace SitefinityWebApp
{
    public partial class RetrieveFullPageURLExample
    {
        public string RetrievePageAbsoluteURL(PageSiteNode pageNode, CultureInfo culture)
        {
            string url = string.Empty;
            MultisiteContext multisiteContext = SystemManager.CurrentContext as MultisiteContext;
            UrlLocalizationService s = ObjectFactory.Resolve<UrlLocalizationService>();

            ISite site = multisiteContext.GetSiteBySiteMapRoot(Guid.Parse(pageNode.RootNode.Key));

            if (site != null)
            {
                string domain = (site.RequiresSsl ? "https://" : "http://") + site.LiveUrl;
                url = domain + s.ResolveUrl(pageNode.GetUrl(culture), culture).Trim('~');
            }

            return url;
        }
    }
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?