Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Response.BinaryWrite file download being block with SSL

Tags:

asp.net

I have a page that generates a dynamic file for download, and sends it to the client using Response.BinaryWrite.

Everything seems to work fine, except when we moved it to a test server with SSL. The download happens in a new window, and what I'm seeing (in IE7/8 but not chrome or FF) is the tab opens, and closes, but no File Dialogue is shown.

Here's the complete header write:

Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/octet-stream"
        Response.AddHeader("Content-Length", abytFileData.Length.ToString)
        Response.AddHeader("cache-control", "private")
        Response.AddHeader("Expires", "0")
        Response.AddHeader("Pragma", "cache")
        Response.AddHeader("content-disposition", "attachment; filename=""" & pMsg!pstrFileName & """")
        Response.AddHeader("Accept-Ranges", "none")
        Response.BinaryWrite(abytFileData)
        Response.Flush()
        Response.End()

I thought for sure that my problem was what was mentioned here,

But my cache-control heade is correct. Any ideas?

like image 236
Gaidin Avatar asked Dec 08 '09 21:12

Gaidin


1 Answers

See answer here:

C# BinaryWrite over SSL

Essentially, replace:

Response.Clear();

with ...

Response.ClearContent();
Response.ClearHeaders();
like image 198
Keith Adler Avatar answered Nov 15 '22 08:11

Keith Adler