A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Get absoulte URL of ContentReference

ZZ
ZZ
Vote:
 

Hi,

How to get the absolute URL of the content reference ?

        [UIHint(UIHint.Image)]
        [Display(
            Name = "xxx",
            Description = "xxx",
            GroupName = xx,
            Order = 350)]
        public virtual ContentReference TestImage { get; set; }

//I found that this method works, is there any better method ?
 return UrlResolver.Current.GetUrl(pageHelper.GetCurrentPageData().MetaImage, null,
                    new VirtualPathArguments { ForceAbsolute = true });

#307399
Aug 24, 2023 7:26
Vincent - Aug 24, 2023 12:41
I think this is the correct way and from memory Optimizely cms generate absolute url using the same way
Vote:
 

Looks fine. I use: UrlResolver.Current.GetUrl(contentReference, null, new VirtualPathArguments { ForceAbsolute = true });

In a muliti-language solution you might want to include the language, ContentLanguage.PreferredCulture.Name, or the language of the actual page.

#307405
Aug 24, 2023 9:00
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.