protected string ToAbsoluteUrl(string url)
 {
     if (Url.IsLocalUrl(url))
     {
         return(new Uri(new Uri(WebSiteOptions.GetSiteUrlFallbackToContext(HttpContext)), Url.Content(url)).ToString());
     }
     else
     {
         return(url);
     }
 }
Ejemplo n.º 2
0
        protected override void OnBeforeWriteLinkInline(LinkInline linkInline)
        {
            if (!linkInline.Url.StartsWith("http"))
            {
                if (linkInline.IsImage && (!linkInline.Url.Contains('/')) && (!String.IsNullOrWhiteSpace(_webSiteOptions.ImageBasePath)))
                {
                    if (_webSiteOptions.ImageBasePath.EndsWith('/'))
                    {
                        linkInline.Url = $"{_webSiteOptions.ImageBasePath}{linkInline.Url}";
                    }
                    else
                    {
                        linkInline.Url = $"{_webSiteOptions.ImageBasePath}/{linkInline.Url}";
                    }
                }

                var baseUrl = _webSiteOptions.GetSiteUrlFallbackToContext(_httpContextAccessor?.HttpContext);
                if (!String.IsNullOrWhiteSpace(baseUrl))
                {
                    linkInline.Url = new Uri(new Uri(baseUrl), linkInline.Url).ToString();
                }
            }
        }