When registering a custom UrlProvider on a site that uses multiple domains (assigned using the Culture and Hostnames dialog) the Links section shown in the Info tab of a page shows up blank (no page URLs shown). This happens even for a custom UrlProvider that just inherits from the DefaultUrlProvider without any code changes.
test.com and test.org.
UrlProvider class that inherits from the DefaultUrlProvider (the GetUrl and GetOtherUrls methods will not be overridden, so it's just a 'copy' of the DefaultUrlProvider): public class SiteUrlProvider : DefaultUrlProvider
{
public SiteUrlProvider() : base(UmbracoConfig.For.UmbracoSettings().RequestHandler)
{
}
public SiteUrlProvider(IRequestHandlerSection requestSettings) : base(requestSettings)
{
}
}
UrlProvider in an ApplicationEventHandler that you also include in your project:public class ApplicationEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
UrlProviderResolver.Current.InsertTypeBefore<DefaultUrlProvider, SiteUrlProvider>();
}
}

The list of URLs available for that node.
No URLs are shown.
The page URLs on the frontend work fine, so the UrlProvider is still doing some of it's job.
Hi @tomvanenckevort
Thanks for reporting this and leaving such detailed notes on it too.
I've replicated this error so I'm tagging it as up-for-grabs
Emma, Pull Request team
Hi @tomvanenckevort
Is this also the case with UrlProvider that actually creates a custom url ?
Because the example her is really a edge case. I think in cases you would inherit from the default url provider you would actually replace the default one instead of adding it
Dave
Hi @dawoe,
Yes, it does also happen when there is code to actually create custom URLs. That's what I initially did on the project where I first encountered this bug.
The reason why I used a simplified example here with no custom URLs is to rule out that my code was causing the issue.
Hi @tomvanenckevort
I can't reproduce on the latest code base using the url provider in this PR #3837 (needs starter kit)
Dave
So I did a bit further digging into this issue by stepping through the Umbraco code.
I noticed that the request that returns the node JSON for the CMS had three URLs in its response:
Since there is a duplicate URL in there, the AngularJS ng-repeat that displays the links in the Info tab fails (since it can't deal with duplicate values in the list).
So the next step was to find out why there was a duplicate URL in there.
I started in the Umbraco.Web.Editors.ContentController class and the GetById method and traced back the Url mapping to the ContentModelMapper class, which in turn calls the GetContentUrls method where the UrlProviders come into play.
It calls the GetOtherUrls method and on this line it will invoke all registered UrlProviders and add all the URLs it returns into the list.
And there it dawned on me the mistake I made. Since I have registered two UrlProviders (the DefaultUrlProvider and my custom SiteUrlProvider) they both get called there and that's why the duplicate URLs end up in the list returned in the API controller.
So in this case I had to change my ApplicationEventHandler and make sure to remove the DefaultUrlProvider after registering my custom SiteUrlProvider:
public class ApplicationEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
UrlProviderResolver.Current.InsertTypeBefore<DefaultUrlProvider, SiteUrlProvider>();
UrlProviderResolver.Current.RemoveType<DefaultUrlProvider>();
}
}
And after that change my URLs show up correctly in the CMS again 馃槃
So I'm going to close this issue now, since I don't think there is a code issue at all (but just an implementation issue on my side 馃槈).
Thanks for the explanation @tomvanenckevort - glad it's resolved for you!
@tomvanenckevort thanks for providing the details on how you resolved this. We have an older site which was doing the same thing and your solution worked for us.