I'm developing a web service (WCF) inside SF (9.1) which should return some of the page data, most importantly in this case - actual front-end page URL. I have couple of multi-sites, like example.com (default), example.com/msite1, example.com/msite2 etc.
I've tried to apply the solution described in documentation (docs.sitefinity.com/for-developers-retrieve-page-url):
var pageNode = page.NavigationNode;
var siteMap = SiteMapBase.GetCurrentProvider();
var siteMapNode = siteMap.FindSiteMapNodeFromKey(pageNode.Id.ToString())
var url = siteMapNode.GetUrl(CultureInfo.CurrentCulture,
but it returns the url of the default multi-site, that is: http://example.com/page-url instead of example.com/.../page-url
Since most of the operations related with multi-sites and sites in API are performed in static context (!) I also tried to statically switching to the target multi-site context:
var multisiteContext = SystemManager.CurrentContext
var currentMultisite = multisiteContext.CurrentSite;
var targetPageMultisite = multisiteContext.GetSiteBySiteMapRoot(page.NavigationNode.RootNodeId);
var result =
DisplayUrl = UrlPath.ResolveAbsoluteUrl(page.NavigationNode.GetFullUrl(),
but with exactly the same result as above.
This operation is so basic that I cannot imagine how it was made so complex in SiteFinity SDK...
Please advice how can I retrieve the proper absolute URL of specific page including its multi-site context.
Unfortunately it's not.
Please, read topic and content of the question carefully - I'm having problem with resolving page URL, not with retrieving the pages and their data
Hi Marek, that what i did for my multisite
var multisiteContext = SystemManager.CurrentContext;
var currentSite = multisiteContext.CurrentSite;
var domain = (currentSite.RequiresSsl ?
) + currentSite.LiveUrl;
var url = domain + pageNode.GetUrl(culture).Trim(
This should work for you
You can try to receive specific site and take liveUrl from site
var targetPageMultisite = MultisiteManager.GetManager().GetSites().First(s=>s.SiteMapRootNodeId == page.NavigationNode.RootNodeId);
var domain = (targetPageMultisite.RequiresSsl ? "https://" : "http://") + targetPageMultisite.LiveUrl;
It should allows you to receive all multisite urls
Your solution works well when you run it in the context (URL) of the proper multi-site, but it does not work in my case.
Please note that multisiteContext.CurrentSite works in a static context so it simply cannot return the proper multi-site URL when you run the code from a default multi-site only (as in this case).
May be targetPageMultisite is incorrect.
This method MultisiteManager.GetManager().GetSites() working fine for me. All sites have correct LiveUrl property.
Thank you for the hint but this doesn't work either (tested). The 'targetPageMultisite.LiveUrl' property does not resolve properly to multisite url.
I don't know if it's relevant, but in my case all the multisites are in single domain but on different paths:
* Default multisite: http://example.com/
* Multisite A: http://example.com/a/
* Multisite B: http://example.com/b/
The 'targetPageMultisite.LiveUrl' always resolves to the default multisite URL.