I. The server outputs the corresponding HTTP Response Headers information via the response, and the data to download files to the client, HTTP Response Headers is in the HTML file: http-equiv denotes the name of Headers, Content means the value of this Headers
Second. First, to output the MIME type of the file: page.response.addheader ("Content-Type", "MIME Type");
Third. Second, to output the open position and file name of the downloaded file: page.response.addhead ("content-disposition", "attachment; filename =" filename); Content-Disposition HTTP Response Header allows the designated documentation information. With this header, you can specify a document separately (instead of opening in the browser), and can also be displayed according to the user's operation. If the user wants to save the document, you can also recommend a file name for the document. This suggestion name will appear in the File Name column of the Save AS dialog. Attachment - Represents as an attachment to the client, the client will open this file separately. Inline - indicates that this file will be opened in the browser. FileName - Indicates the file name sent to the client file.
IV. Prepare file data sent to the client: No matter what type of files must be transferred to the array of Byte types, then output this BYTE array with the response.binarywrite method to the client.
String path = "g: //download//down.txt"; system.io.fileinfo file = new system.io.fileinfo (path); response.clear (); response.addheader ("content-disposition", " attachment; filename = " httputility.urlencode (file.name));
Response.addheader ("Content-length", file.Length.Tostring ()); response.contentType = "Application / OcTeet-stream"; response.writefile (file.fullname); response.end ();