Skip to content
May 28, 2011 / kiranpatils

Render file in browser rather than showing OpenSaveDialog


One of my friend asked me that he is requesting XML file which has been uploaded in Sitecore using javascript for fetching XML content. But it fails as when he hits that XML URL directly in browser it shows OpenSave Dialog box of browser. Which he wanted to disable.


Basically, This is being manged using Web.Config’s MediaType configuration here  <forceDownload>true tag plays a vital role in deciding whether to render or show open save dialog for request media item.If forceDownload is true then it will show OpenSave dialog else it won’t! — Easy right?

Sitecore says :

A true value for the forceDownload element causes Sitecore to apply an HTTP “Content-
Disposition = attachment; filename=” header when linking to the .ashx URL of the media item,
causing the browser to prompt the user to open/save as rather than opening the resource in the

So, Open you web.config file and find mediaType for your desired extension on which you would like to disable ForceDownload [In this case it’s XML] and set forceDownload to false.

<mediaType name="XML document" extensions="xml">
<generator type="Sitecore.Resources.Media.MediaThumbnailGenerator, Sitecore.Kernel">

Just a note : Browser should also have proper plugin to render the requested media file. E.g. If you set forceDownload false for PDF files than PDF plugin should be there in your browser.

Worth to read :

Happy Media serving! 🙂



Leave a Comment
  1. Shafaqat Ali / Jul 31 2014 7:22 am

    thanks for this, is it possible to set force download=true for some files and force download=false for some other files?

    • kiranpatils / Aug 3 2014 10:09 pm

      Hello Shafaqat,

      You are welcome! Sorry, haven’t understood your question. But as per my understanding you would like to do force download = true for particular PDF Files and false to other files — is it so? If so, then what will be your logic? Curious to know the reason. The way is : In custom media handler.

      If you would like to do it based on extension then it’s super easy — just add particular extension mediaType



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: