Let have example structure:
Normally when there is no SXA tenants
exist and New Sample Item
is published, LinkBuilder.GetItemUrl()
will return something like
https://sc93sc.dev.local/en/New-tenant/New-site/Home/New-Sample-Item
.
The problem is when SXA tenants are there. Then link should be created referring to it.
In short, I'm getting URL something like above which returns 404 when I try to use it. To make it work link has to be
https://sc93sc.dev.local/en/New-Sample-Item
, so relative to tenant root, not Sitecore root.
Is there a way to get that without custom LinkProvider?
Code:
var siteName = "website"; var site = SiteContext.GetSite(siteName); var options = new UrlOptions { AlwaysIncludeServerUrl = true, Site = GetSiteForPreviewLink(), Language = Language.Parse(language.Name) }; var builder = new LinkProvider.LinkBuilder(options); link = builder.GetItemUrl(sitecoreItem);
LinkProvider
for Item URL? if yes, did you try by usingLinkManager.GetItemUrl
instead of it?sc93sc.dev.local
added as a valid URL to the Site Grouping ofNew Site
?