Thursday, September 29, 2005
Today I stumbled across an interesting issue that came to light only after moving a product to a production server which uses SSL (HTTPS). We had a page that exported some data as an Excel CSV file, by setting the Content-Disposition. Works great on the dev server, but on the live server, Internet Explorer was returning "File not found", with a seemingly random (incorrect) filename. At it refused to download the file.
After quite a bit of digging, and determining that it was a bug with IE... I stumbled across this page which outlined the fix.
Here is the working code in VB.NET:
Response.CacheControl = "private"
Response.Charset = System.Text.UTF8Encoding.UTF8.WebName
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment;filename=" & fname)
Lead Software Developer