I use the following block of code to generate the links of media items in a specific language:
Sitecore.Links.UrlOptions urlOptions = Sitecore.Links.LinkManager.GetDefaultUrlOptions(); urlOptions.AlwaysIncludeServerUrl = true; urlOptions.Language = Language.Parse(item.Lang); string lnk = Sitecore.Links.LinkManager.GetItemUrl(pdfItem, urlOptions); ... linkfield.Url = lnk;
The link generated looks like this:
My problem is it keeps redirecting me to the last language version i clicked on. It seems to be a cache problem because when i click the link opening my media, if the pdf opened in a new window is in the wrong language, i just need to refresh the page and then the pdf appears in the right language.
Did i miss some useful options in my
urlOptions object ?