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

Last reviewed: March 12, 1998
Article ID: Q182315
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), version 4.01

SYMPTOMS

According to the Web site http://ds.internic.net/rfc/rfc2183.txt, setting a Content-Disposition header with type "attachment" when returning a file to a client, should force the client to prompt the user for input. Typically this input would indicate whether the user wishes to view or store the file. Internet Explorer 4.01 may attempt to open the returned file without prompting the user.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

When a document file for an application installed on a client is first opened in the Internet Explorer, the Explorer will present the user with a File 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 of this type.

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

Internet Explorer 4.01 does support the Content-Disposition header in that it will initialize the File Download dialog box (if it does appear) with a suggested file name. The following code demonstrates how to send the Content-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 it in quotes.

You might think that setting the Content-Type to a type unknown to Explorer would 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. If it recognizes the file type, it will behave according to the user preference. At this point, there is no completely reliable way to force the File Download dialog box to appear when downloading a file to Internet Explorer.

REFERENCES

http://ds.internic.net/rfc/rfc2183.txt

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Robert Duke, Microsoft Corporation


Additional query words: kbdsi
Keywords : ISAPIext
Version : WINDOWS:4.01
Platform : WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 12, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.