I figured out a simple solution based on the standard Umbraco library. Take the absolute URL of a page https://www.example.com/some/page and trim out the relative part /some/page so only the hostname https://www.example.com is left. It should work no matter which page node you feed into it:
How to get hostname part of a page URL?
Let's imagine a page with
/some/pageas path and an absolute URL ofhttps://www.example.com/some/page.How do I isolate and get the hostname part including scheme
https://www.example.comdynamically?I figured out a simple solution based on the standard Umbraco library. Take the absolute URL of a page
https://www.example.com/some/pageand trim out the relative part/some/pageso only the hostnamehttps://www.example.comis left. It should work no matter which page node you feed into it:Also, I found a few other solutions courtesy of Paul Seal that might be relevant to others.
is working on a reply...
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