I'm trying to create a custom routes for a package dynamically in a ApplicationEventHandler. I'm trying to use existing node url to form the route. However when I use the Umbraco Helper
var pageData umbracoHelper.ContentQuery.TypedContent(page.Id);
pageData.Url returns the absolute I'm trying to get the relative url to the domain.
I was thinking of an extension method which removes the host but wondered if there was a native method?
For instance, the relative part is /some/page
of an absolute URL https://www.example.com/some/page, which you can get by setting the mode to UrlMode.Absolute.
Url without Domain
Hi,
I'm trying to create a custom routes for a package dynamically in a ApplicationEventHandler. I'm trying to use existing node url to form the route. However when I use the Umbraco Helper
pageData.Url returns the absolute I'm trying to get the relative url to the domain.
I was thinking of an extension method which removes the host but wondered if there was a native method?
Hi John
It looks like "useDomainPrefixes" is set to true in your solution.
You can change it in /config/umbracoSettings.config
/Alex
Hi Alex,
"useDomainPrefixes" is set to false thanks for the suggestion. I ended up using an exension method with the following code:
John
Hi John
Thanks for sharing the solution, have a great day
/Alex
Have you tried this method?
For instance, the relative part is
/some/page
of an absolute URLhttps://www.example.com/some/page
, which you can get by setting the mode toUrlMode.Absolute
.Find more info in the documentation.
is working on a reply...