Problem with webclient.downloaddata

G

gom

I am using the following code to stream a server generated pdf file to a
client. Acrobat 7 opens the file as expected but Acrobat 5,6 and 8 launch
in memory but never open. I ran the command with Fiddler running and it
tells me there is a content-length mismatch of 129 bytes between my buffer
length and what the server actually sends. I'm wondering if this is an
issue related to some additional header information or something that is
sent along with the buffer. Can anyone help me with this?

Thanks in advance.

Dim client As New System.Net.WebClient()
Dim buffer As Byte() = client.DownloadData("http://www.mywebsite.com" &
myResponseString.ToString)

If buffer IsNot Nothing Then
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
End If
 
B

bruce barker

try:

Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.AddHeader("content-disposition","inline;filename=report.pdf")
Response.BinaryWrite(buffer)
Response.End()

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top