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 ?

  • Have you tried using the Sitecore.Resources.Media.MediaManager.GetMediaUrl() method to generate your media links instead? Commented Dec 6, 2018 at 15:04

2 Answers 2


For media items you should use the MediaManager to generate links instead of the LinkManager. The MediaManager will return a link to the actual media item.

var urlOptions = new MediaUrlOptions();
urlOptions.Language = Language.Parse(item.Lang)                
var lnk = MediaManager.GetMediaUrl(item);

Try including the LanguageEmbedding option in your UrlOptions:

urlOptions.LanguageEmbedding = LanguageEmbedding.Always;

That should result in a URL that has the language in the querystring, like so:


  • Thank you for your help. Unfortunately the language still does not appear in the querystring. Do you know what might cause this problem ?
    – Slrg
    Commented Dec 6, 2018 at 14:30
  • Do you have different settings specified for your link provider in the config? You can check by going to /sitecore/admin/showconfig.aspx and searching for Sitecore.Links.LinkProvider. The attribute to look for is languageEmbedding. Commented Dec 6, 2018 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.