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.AppendHeader("Content-Length", f.Length.ToString())
Response.AppendHeader("Pragma", "cache")
Response.AppendHeader("Expires", "60")
Response.ContentType = "application/"
Response.AddHeader("Content-Disposition", "attachment;filename=" & fname)
Response.Write(filecontents) Response.End()

Dusty Davidson
Lead Software Developer


Recent Entries

Blogs we read

Page 1 Of 1 (1 items)