Ejemplo n.º 1
0
        /// <summary>
        /// Gets the absolute value of the canonical URL, finding the value by
        /// <see cref="P:MvcSiteMapProvider.ISiteMapNode.CanonicalKey"/> if necessary.
        /// </summary>
        /// <returns>The absolute canonical URL.</returns>
        protected virtual string GetAbsoluteCanonicalUrl()
        {
            var url = this.canonicalUrl;

            if (!String.IsNullOrEmpty(url))
            {
                if (urlPath.IsAbsoluteUrl(url))
                {
                    return(url);
                }
                return(urlPath.MakeRelativeUrlAbsolute(url));
            }
            var key = this.canonicalKey;

            if (!String.IsNullOrEmpty(key))
            {
                var node = this.SiteMap.FindSiteMapNodeFromKey(key);
                if (node != null)
                {
                    url = node.Url;
                    if (urlPath.IsAbsoluteUrl(url))
                    {
                        return(url);
                    }
                    return(urlPath.MakeRelativeUrlAbsolute(url));
                }
            }
            return(String.Empty);
        }