U4-9401 - Double slashes in some Umbraco generated urls causes broken links

Created by Simon Dingley 18 Jan 2017, 11:10:46 Updated by Sebastiaan Janssen 31 Oct 2017, 22:22:35

Tags: Backport Unscheduled PR

We have a large load balanced install hosting multiple sites and it periodically has a problem whereby some links are generated with a double slash at the start of the path to the document. It doesn't affect all urls and it is usually rectified by publishing the document. The problem is that .Url property on the front end results in broken links as a result.

Relevant appsettings from the web.config in case they are of use:

Relevant settings from umbracoSettings.config:

true true

I can't as yet find a way to force this to happen so it's a bit hard to replicate.

1 Attachments


Tim Payne 18 Jan 2017, 16:00:41

Do you have any custom URL Providers? We had this problem on a load balanced site we inherited, and that's caused by an issue with one of the URL providers.

Simon Dingley 18 Jan 2017, 16:31:57

Yes, there is one custom url provider DateFolderUrlProvider which formats news/blog/press items to have the dates in the urls. I'll look at that but I wonder why it is intermittent - I'd expect it to be consistent.

Simon Dingley 20 Jan 2017, 11:27:04

I looked further at this and the doctypes affected by this issue are not using the Url Provider and so that seems unrelated to the issue. Furthermore, this morning when the issue returned and I looked at the node url on the properties tab there were 3 forward slashes e.g. https://example.com///path/to/document/

Kevin Farrugia 02 Jun 2017, 09:01:42

I have the same issue and have attached a screenshot where the Link to Document is displaying incorrectly too.

Same web.config and umbraco.config as above.

Umbraco version 7.5.3

Phil Dye 13 Jun 2017, 14:06:54

I'm seeing the same with a particular node on a site, and at first thought it was using an IUrlProvider, but it's not (although we do have an IContentFinder for it, instead of a url rewrite).

However, we're not using domain prefixes;



<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoUseDirectoryUrls" value="true" />

It happens at random, generating the url as //blog, until you manually hit /blog, at which point it reverts for a while to working OK.

Shola 18 Oct 2017, 21:27:04

This has happened to me with extra trailing slashes. It happens any time I use the method UmbracoContext.Current.ContentCache.GetByRoute() Basically, I had to remove all calls of that function and republish the site to fix things.

Simon Dingley 19 Oct 2017, 10:56:02

That's interesting! Are you saying that's what triggers the problem or the content item you get back from a call to GetByRoute() has a url that contains a double slash? IN fact, I think this rings true perhaps with what @AttackMonkey said above about it being triggered by a UrlProvider or more likely the corresponding ContentFinder which very likely makes a call to UmbracoContext.Current.ContentCache.GetByRoute() .

Tim Payne 19 Oct 2017, 12:15:27

We don't look after the site this was on any more, but looking through the old source code, there are calls to that method in a custom content finder.......

Shola 19 Oct 2017, 15:48:04

In my experimentation, any direct calls to UmbracoContext.Current.ContentCache.GetByRoute(), whether it's from a custom content finder or not, will for some reason yield this issue. You'd think the method is purely read-only and would not affect the .Url property of an IPublishedContent object, but it does. Even when you view the Properties tab, the "Link to document" field will look like this for me: /hello/// Very strange indeed.

Simon Dingley 20 Oct 2017, 07:39:27

Hmm, this looks like a problem with trailing slashes which I see less often, the issue we keep experiencing is the leading slashes. At least now I think we've identified a part of the Umbraco source to start looking at.

Paul Gower 25 Oct 2017, 14:39:38

@ProNotion We are seeing this same issue on our website and oddly enough we are using the same call mentioned above: this.UmbracoContext.ContentCache.GetByRoute()

Is anyone at @devteam looking into this issue? It's very strange that something is affected by calling what we assume is a read-only function.

Shola 25 Oct 2017, 15:36:58

@paul.gower@lunamark.com and all: It might help to check the "Affected versions" on the right if you're using the latest version of Umbraco and still have the issue, and vote if you haven't already.

Paul Gower 25 Oct 2017, 15:41:13

Good point @oooshola. I have updated it with the version I am using and still seeing the issue. The only way I know to resolve it for a node with this issue is to republish the node in the umbraco back office.

Does anyone have any work arounds to resolve this issue? Thankfully our site is not live yet but for demos with the client it is a pain to check all the Urls, etc.

Simon Dingley 26 Oct 2017, 13:34:19

Pretty much ruined my day so far but I think I have finally found the issue and have submitted a [pull request|https://github.com/umbraco/Umbraco-CMS/pull/2266]. In the UriUtility class there is a method called [UriToUmbraco|https://github.com/umbraco/Umbraco-CMS/blob/dev-v7.6/src/Umbraco.Web/UriUtility.cs#L73] where if the AddTrailingSlash option is enabled in your config it will basically append a forward slash without first checking if there is already a trailing slash.

That was tough (for me anyway) to track this down as it was not easy to step through and find where it was occurring.

Shannon Deminick 27 Oct 2017, 03:31:42

Great sleuth work! much appreciated :) will merge the PR asap

Paul Gower 27 Oct 2017, 04:26:03

@Shandem any chance we can get a patch for 7.6.* version of umbraco for those of us that aren't ready to upgrade to 7.7.* due to all the user changes?

Shannon Deminick 27 Oct 2017, 07:33:26

Yes I've added the back port tag so when we release another 7.6 we can include it

Sebastiaan Janssen 31 Oct 2017, 22:22:35

Also fixed for 7.6.12 - https://github.com/umbraco/Umbraco-CMS/commit/84b380028c929c6deac80ccaf75566c99740ac7c

Priority: Normal

Type: Bug

State: Fixed


Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions: 7.5.3, 7.6.4

Due in version: 7.7.5, 7.6.12


Story Points: