Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1465 posts 1887 karma points
    May 24, 2022 @ 13:12
    Gordon Saxby
    0

    How do I get the full Url including port for an IPublishedContent

    Having obtained a node as IPublishedContent, I want to get the full Url of it.

    I tried homePage.Url() but that only gives me "https://localhost/" but the site is running (via Visual Studio) at "https://localhost:44311/"

    How do I get the full path including the port?

    Edit:

    Both of these fail to return the Port (they all return "https://localhost/"):

    var x = _publishedUrlProvider.GetUrl(homePage, UrlMode.Absolute);
    var y = homePage.Url(mode: UrlMode.Absolute)
    

    Also tried

    var z = new Uri(homePage.Url(mode: UrlMode.Absolute), UriKind.Absolute);
    
  • Gordon Saxby 1465 posts 1887 karma points
    May 25, 2022 @ 07:58
    Gordon Saxby
    100

    Apparently, you HAVE to configure "Culture and hostnames" with the full Url if it has a port number, otherwise the Url() method won't return the correct / actual Url.

    So, I had "/" for "en" and had to change it to "https://localhost:44311/" so that the Url() method on IPublishedContent actually returned the full Url.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" button below.

    Continue discussion

Please Sign in or register to post replies