files served with content-disposition: inline still sometimes prompt for download

rmeador picture rmeador · Apr 21, 2009 · Viewed 9.8k times · Source

My subject line says most of what I'm asking. I've got a web site that outputs reports in various formats (HTML, CSV, TSV, Excel, etc). Whenever possible, I'd like these files to be shown in the browser. To that end, I've set up my headers so that "Content-Disposition" is "inline". This works very inconsistently with different file types. It seems that in both FF3 and IE7, HTML will always open inline automatically. That makes sense. If I use TSV, both browsers will prompt for download, since it's an unknown file type on my system. That also makes sense and is exactly what I want. Excel and CSV, however, offer different behaviors. In FF, both always prompt for download or opening. If I choose "open", it opens in a new window. In IE, both also prompt for download or opening -- I can't figure this one out. I thought Excel files opened inline automatically with Content-Disposition: inline. If I choose "open" in IE, it opens inline in the browser.

Can someone explain the unexpected behavior? This isn't really a problem for me, but my users think it's a bug, so an authoritative source I can cite to them would be excellent. The only thing I've found so far about this "issue" is a 1 line post on a mozilla forum about how the auto-open-inline thing is one of IE's security flaws... that was an old post, so maybe it was "fixed" in IE7? Thanks.

Answer

Chris picture Chris · Dec 7, 2009

You may have resolved this already, but if not I may have an answer (for future people with the same issue, this also drove me nuts!)

This behavior can be overwritten on the client, using the following:

  1. Go to windows explorer
  2. Select Tools -> Folder Options
  3. Select “File Types” Tab
  4. Find extension “DOC” (or “PDF”, etc)
  5. Select “Advanced”
  6. Tick / Untick “Confirm open after download” as desired.

The mechanism used to implement the preview / download functionality is via the use of the “content-disposition” header, usually using MimeType “application/”. This basically tells the local client to open the application using the specified application, however the above settings for the application can overwrite the requested delivery format.