You are currently offline, waiting for your internet to reconnect

FIX: Content-Disposition: Does not Force File Download Dialog

This article was previously published under Q182315
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Symptoms
According to the Web site http://www.nic.mil/ftp/rfc/rfc2183.txt setting aContent-Disposition header with type "attachment" when returning a file toa client, should force the client to prompt the user for input. Typicallythis input would indicate whether the user wishes to view or store thefile. Internet Explorer 4.01 may attempt to open the returned file withoutprompting the user.
Status
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This bug was corrected in Internet Explorer 5.
More information
When a document file for an application installed on a client is firstopened in the Internet Explorer, the Explorer will present the user with aFile Download dialog box prompting the user with the following options:

  • Open this file from its current location
  • Save this file to disk
This dialog box also presents the user with the following check box:
Always ask before opening this type of file
Once the user clears this check box, Explorer will always open files ofthis type.

When a file is returned to the Explorer with a Content-Disposition headerwith type "attachment," Explorer should prompt the user regardless ofthe above selection. In fact, Explorer may not always prompt the user.

Internet Explorer 4.01 does support the Content-Disposition header in thatit will initialize the File Download dialog box (if it does appear) with asuggested file name. The following code demonstrates how to send theContent-Disposition header and a suggested file name from a CGI program:
   #include <stdio.h>   int main()   {     char szContentType[]="Content-Type: bad/type\r\nContent-Disposition:"                          " attachment; filename=name.xxx\r\n\r\n";     printf(szContentType);     printf("This is a test.");     return 0;   }				
Do not include a path in the file name parameter. Also, do not enclose itin quotes.

You might think that setting the Content-Type to a type unknown to Explorerwould force the File Download dialog box. In fact, the Explorer "sniffs"the data sent from the server and detects the type of file being sent. Ifit recognizes the file type, it will behave according to the userpreference. At this point, there is no completely reliable way to force theFile Download dialog box to appear when downloading a file to InternetExplorer.
kbdsi
Properties

Article ID: 182315 - Last Review: 11/13/2012 08:32:00 - Revision: 2.0

  • kbbug kbDSupport kbfaq KB182315
Feedback
/html>/script>