Get absolutUrl from a linkmodel

I need to get the absoluteUrl for a page that I have the linkmodel for. Any tips how i can achive this?

My current solution is based on earlier asp.net mvc skills, it feels like this could be achieved in a easier way trough some service inside Litium. Someone have any tip och help to give me?

     var request = HttpContext.Current.Request;
                    var appUrl = HttpRuntime.AppDomainAppVirtualPath;
                    if (appUrl != "/")
                        appUrl = "/" + appUrl;
                    var url = $"{request.Url.Scheme}://{request.Url.Authority}{appUrl}{setNewPasswordLinkModel.Href}";

Litium version: 7.4.2

You can use _routeRequestLookupInfoAccessor.RouteRequestLookupInfo.AbsolutePath or other properties in that.

1 Like

How are you creating the LinkModel? can you use the UrlService.GetUrl(page, new PageUrlArgs(channelSystemId){ AbsoluteUrl = true; } instead to get the url?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.