C # BinaryWrite over SSL

I am trying to respond to a client with a PDF stored in the MSSQL varbinary (MAX) field. The answer works on my local host and test server over the http connection, but does not work on the production server via the https connection. I am using just BinaryWrite (code below).

    byte[] displayFile = DatabaseFiles.getPdfById(id);

    Response.ContentType = "application/pdf";
    Response.BinaryWrite(displayFile);

Nothing special here. Just take the binary data, set the content type and write back to the client. Is there anything special that needs to be done in order to respond to https in this way?

Change: . It doesn’t work, I mean that I get an empty document in the browser. Acrobat does not load in the browser.

Edit: I just noticed that this problem only occurs in IE 7. PDF loads correctly in Firefox 3. Our client only uses IE 7 (better than IE 6, which I convinced them to update from ... lol).

Change: . I tried adding the header "content-disposition" so that the file works as an attachment. Browser failed to load under SSL with IE error "Internet Explorer cannot load displayFile.aspx from ProductionServer.net". (Code below)

    byte[] displayFile = DatabaseFiles.getPdfById(id);
    Response.Clear();
    Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(displayFile);

Edit: If the file is viewed via http on the Production Server, the browser displays the code for the PDF as it is viewed through NotePad. (e.g.% PDF-1.4% âãÏÓ 6 0 obj <> endobj xref 6 33 ... etc.)

+4
6

,

Response.Clear();

Response.ClearContent();
Response.ClearHeaders();

:

byte[] downloadBytes = doc.GetData();
Response.ClearContent();
Response.ClearHeaders();

Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Length", downloadBytes.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=myFile.pdf");
Response.BinaryWrite(downloadBytes);
Response.Flush();
Response.End();
+8

IE 7 / mime "issue" PDF, mime. , .

IE 7 ( script, response.flush keepalives ), AFAIK .

, , - .

.pdf ASP.NET, URL- PDF IE. mime.

(HTTP Response.Redirect, Javascript ), , .

IIS keepalive Fiddler , keepalives.

, content-disposition ... .

, SSL - , -SSL .

+1

. IE. ​​, <%@ OutputCache Location="None" %> .aspx. , , Response.ClearHeaders .

+1

. , , . Response.Redirect.

0

Wireshark ( ), , ?

0
source

Here is the raw request as viewed in Fiddler

GET /displayFile.aspx?id=128 HTTP/1.1
Accept: */*
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
Host: ProductionServer.net
Connection: Keep-Alive

Edit: Here are the original response headers that are viewed in Fiddler

HTTP/1.1 200 OK
Date: Wed, 10 Dec 2008 18:39:54 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: application/pdf; charset=utf-8
Content-Length: 102076
0
source

All Articles