Last post Dec 21, 2006 01:29 AM by GeorgeZ
Dec 01, 2006 04:04 AM|lordfkiller|LINK
I have a download handler which gets an ID and retrieves a file from database. The following information is returned from database:
data(binary data) name(file name) mime type
It writes "data" to output stream and sets mime type. But when browser wants to download the file, it calls the file "DownloadHandler.axd" which is the name of handler.
What do I have to do to send correct file name("name")?
Thanks for your help,
Dec 06, 2006 12:42 AM|GeorgeZ|LINK
I'm wondering if the ContentType set correctly by your HttpHandler.
Usually client will determine the file name by its URL too.
Dec 06, 2006 06:55 AM|lordfkiller|LINK
ContentType header is correct. I think I have found the solution, but not sure.
I append a CONTENT-DISPOSITION header with this value: "attachment; filename=" + filename. This works for FireFox, but in IE, I get an error.
Dec 21, 2006 01:29 AM|GeorgeZ|LINK
There are " around the filename, don't forget to add them. here is one example for .csv file.
Content-Disposition: attachment; filename="report.csv"