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:
http://cd5-int.global.com/-/media/Files/Mediaroom/700767.pdf
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 ?
Sitecore.Resources.Media.MediaManager.GetMediaUrl()
method to generate your media links instead?