Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Getting stackoverflow errors with LinkURL on shortcut urls that are setup for international language pages to English (within the site)

Vote:
 

With the new nuget package updates, we are getting stackoverflow errors with LinkURL on shortcut urls setup for international language pages to English (within the site). Can you check out follows and advise is this implementation is correct specifically the public static string ContentUrl(this IUrlHelper urlHelper, ContentReference contentLink, string queryStringAppend)

public static class UrlHelpers
    { /// <summary>
      /// Returns the target URL for a ContentReference. Respects the page's shortcut setting
      /// so if the page is set as a shortcut to another page or an external URL that URL
      /// will be returned.
      /// </summary>
        public static Microsoft.AspNetCore.Html.HtmlString LinkUrl(this UrlHelper urlHelper, ContentReference contentLink)
        {
            if (!contentLink.HasValue())
            {
                return Microsoft.AspNetCore.Html.HtmlString.Empty;
            }

            var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
            var page = contentLoader.Get<PageData>(contentLink);

            return LinkUrl(urlHelper, page);
        }

        /// <summary>
        /// Returns the target URL for a page. Respects the page's shortcut setting
        /// so if the page is set as a shortcut to another page or an external URL that URL
        /// will be returned.
        /// </summary>
        public static Microsoft.AspNetCore.Html.HtmlString LinkUrl(this UrlHelper urlHelper, PageData page)
        {
            var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
            switch (page.LinkType)
            {
                case PageShortcutType.Normal:
                case PageShortcutType.FetchData:
                    return new HtmlString(urlResolver.GetUrl(page.ContentLink));

                case PageShortcutType.Shortcut:
                    var shortcutProperty = page.Property["PageShortcutLink"] as PropertyPageReference;
                    if (shortcutProperty != null && shortcutProperty.ContentLink.HasValue())
                    {
                        return urlHelper.LinkUrl(shortcutProperty.ContentLink);
                    }
                    break;

                case PageShortcutType.External:
                    return new HtmlString(page.LinkURL);
            }
            return HtmlString.Empty;
        }

        public static string ContentUrl(this IUrlHelper urlHelper, ContentReference contentLink, string queryStringAppend)
        {
            if (queryStringAppend.HasValue())
            {
                if (contentLink.HasValue())
                {
                    var query = HttpUtility.ParseQueryString(queryStringAppend);

                    UrlBuilder builder = new UrlBuilder(UrlResolver.Current.GetUrl(contentLink));
                    builder.QueryCollection = query;

                    return builder.ToString();
                }
            }
            return urlHelper.ContentUrl(contentLink);
        }

       
    }

#307685
Edited, Aug 30, 2023 15:43
Vote:
 

what is the stacktrace of this stackoverflow exception ?

#307810
Sep 01, 2023 6:11
Vote:
 

Issue is resolved by the patching Episerver did to its packages

#310160
Oct 06, 2023 17:32
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.