Further research confirmed that there are some known IE bugs regarding setting the ContentType and Content-Disposition to support forcing an attachment to be streamed directly to the user via the OPEN/SAVE prompt, opposed to having to actually save the file to disk and worry about disk space, permissions, etc.
Since it took me a while to pin down getting this to work with HTTPS (SSL) I thought I'd go ahead and share the code in case anyone else ran into the same thing.
Response.ClearHeaders()
Response.ContentType = "application/csv"
Response.AppendHeader("Content-Disposition", "attachment; filename=Registrations.csv")
The Response.ClearHeaders() line was the line I had to add to solve the problem.
Apparently this is only a problem with IE browsers and I saw several posts about it and all of them had different solutions proposed, such as setting the Pragma and other header related values, but I couldn't get any of those to work. So I thought if I couldn't change the header values I would simply just clear them all out and set exactly what I needed, which was the ContentType and the Content-Disposition.
After adding that single line of code the page now works for HTTP and HTTPS and from my testing works in all major browsers (IE, Firefox, etc.).
0 comments: