From 0c8a2f1a94b4968d2e56a069d5b34ba3969eb056 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sun, 9 Feb 2014 17:10:43 +0700 Subject: [PATCH] Fixes #267, absolute paths returned from UrlResolver cause exception. --- .../MvcSiteMapProvider/SiteMapNode.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs index e49b65e0..0e257511 100644 --- a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs +++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs @@ -322,14 +322,16 @@ public override string Url { return string.Empty; } - if (!String.IsNullOrEmpty(this.ResolvedUrl)) + if (!string.IsNullOrEmpty(this.ResolvedUrl)) { return this.ResolvedUrl; } // Only resolve the url if an absolute url is not already set - if (this.HasAbsoluteUrl()) + // IMPORTANT: Must not call HasAbsoluteUrl here because that method calls this property. + var unresolved = this.UnresolvedUrl; + if (this.urlPath.IsAbsoluteUrl(unresolved)) { - return this.UnresolvedUrl; + return unresolved; } return GetResolvedUrl(); } @@ -360,7 +362,7 @@ public override string Url /// public override void ResolveUrl() { - if (this.CacheResolvedUrl && String.IsNullOrEmpty(this.UnresolvedUrl) && this.preservedRouteParameters.Count == 0) + if (this.CacheResolvedUrl && string.IsNullOrEmpty(this.UnresolvedUrl) && this.preservedRouteParameters.Count == 0) { this.resolvedUrl = this.GetResolvedUrl(); } @@ -381,7 +383,7 @@ protected string GetResolvedUrl() /// public override bool HasAbsoluteUrl() { - return urlPath.IsAbsoluteUrl(this.url); + return this.urlPath.IsAbsoluteUrl(this.Url); } /// @@ -397,7 +399,7 @@ public override bool HasExternalUrl(HttpContextBase httpContext) return false; } Uri uri = null; - if (Uri.TryCreate(this.url, UriKind.Absolute, out uri)) + if (Uri.TryCreate(this.Url, UriKind.Absolute, out uri)) { return !httpContext.Request.Url.DnsSafeHost.Equals(uri.DnsSafeHost); }