Content-disposition is an extension of the MIME protocol, which indicates how the MIME user agent displays the attached file. Content-disposition In fact, you can control the content of the user request to save as a file when a default file name is provided, the file is directly displayed on the browser or in the Access pop-up file Download dialog box.
Format Description:
Content-disposition = "Content-disposition" ":" Disposition-type * (";" Disposition-parm)
Field Description:
Content-disposition as Property name
Disposition-type is the way to download, such as attachment as an attachment to download
Disposition-parm is the name of the default save
When the server sends a file to the client-side browser, if it is the type of file that is supported by browsers, it will usually be opened by default browser, such as txt, JPG, etc., will be directly displayed in the browser, if you need to prompt the user to save, you must use content-disposition for processing, The key is to add attachment:
Copy Code code as follows:
Response.appendheader ("Content-disposition", "attachment;filename=filename.txt");
Note: So the browser prompts to save or open, even if you choose to open, you will use the associated program such as Notepad to open, rather than ie directly open.
Content-disposition is to provide a default filename when the user wants to save the requested content as a file. The specific definition is as follows:
Copy Code code as follows:
Content-disposition = "Content-disposition" ":"
Disposition-type * (";" Disposition-parm)
Disposition-type = "Attachment" | Disp-extension-token
Disposition-parm = Filename-parm | Disp-extension-parm
Filename-parm = "FileName" "=" quoted-string
Disp-extension-token = Token
Disp-extension-parm = Token "=" (token | quoted-string)
Then there are concrete examples:
Content-disposition:attachment; Filename= "Filename.xls"
Of course the filename parameter can contain path information, but user-agnet ignores this information and only makes the last part of the path information the filename. When you use this header information in response type Application/octet-stream, that means you don't want to display the content directly, but instead pop up a "File download" dialog box, and then you decide whether to "open" or "save".
Precautions :
1. Use content-disposition in your code to make sure that the browser pops up the download dialog box. Response.AddHeader ("Content-disposition", "attachment") make sure you haven't done anything about preventing browser caching. As follows:
Copy Code code as follows:
Response.setheader ("Pragma", "No-cache");
Response.setheader ("Cache-control", "No-cache");
Response.setdateheader ("Expires", 0);
Otherwise will find the download function in opera and Firefox inside Good no problem, in IE below is not