diff --git a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs b/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs index 926db253c8..138155c8f6 100644 --- a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs +++ b/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs @@ -1,18 +1,20 @@ using System; using System.Collections.Generic; using System.Globalization; +using Umbraco.Web.Mvc; +using Umbraco.Core.Models.PublishedContent; namespace Umbraco.Web.Routing { /// - /// This url provider is used purely to deal with umbraco custom routes that utilize UmbracoVirtualNodeRouteHandler and will return + /// This url provider is used purely to deal with umbraco custom routes that utilize and will return /// the URL returned from the current PublishedContentRequest.PublishedContent (virtual node) if the request is in fact a virtual route and /// the id that is being requested matches the id of the current PublishedContentRequest.PublishedContent. /// internal class CustomRouteUrlProvider : IUrlProvider { /// - /// This will simply return the URL that is returned by the assigned IPublishedContent if this is a custom route + /// This will return the URL that is returned by the assigned custom if this is a custom route /// /// /// @@ -30,7 +32,11 @@ namespace Umbraco.Web.Routing if (umbracoContext.HttpContext.Request.RequestContext.RouteData == null) return null; if (umbracoContext.HttpContext.Request.RequestContext.RouteData.DataTokens == null) return null; if (umbracoContext.HttpContext.Request.RequestContext.RouteData.DataTokens.ContainsKey(Umbraco.Core.Constants.Web.CustomRouteDataToken) == false) return null; - //ok so it's a custom route with published content assigned, check if the id being requested for is the same id as the assigned published content + + //If we get this far, it means it's a custom route with published content assigned, check if the id being requested for is the same id as the assigned published content + //NOTE: This looks like it might cause an infinite loop because PublishedContentBase.Url calls into UmbracoContext.Current.UrlProvider.GetUrl which calls back into the IUrlProvider pipeline + // but the specific purpose of this is that a developer is using their own IPublishedContent that returns a specific Url and doesn't go back into the UrlProvider pipeline. + //TODO: We could put a try/catch here just in case, else we could do some reflection checking to see if the implementation is PublishedContentBase and the Url property is not overridden. return id == umbracoContext.PublishedRequest.PublishedContent.Id ? umbracoContext.PublishedRequest.PublishedContent.Url : null;