S
Scott Meddows
I'm trying to serve a PDF file from a webpage so it will load in the
browser.. Can anyone tell what is wrong with this code? I've tried
everything
Thanks
Dim httpwreq As System.Net.HttpWebRequest =
CType(System.Net.HttpWebRequest.Create("http://lafdev2/ReportServeProxy/Migr
ationReport.pdf"), System.Net.HttpWebRequest)
Dim httpWResp As System.Net.HttpWebResponse =
CType(httpwreq.GetResponse, System.Net.HttpWebResponse)
Dim receiveStream As IO.Stream = httpWResp.GetResponseStream
Dim encode As System.Text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")
Dim readstream As System.IO.StreamReader = New
System.IO.StreamReader(receiveStream, encode)
Dim read(256) As Char
Dim count As Integer = readstream.Read(read, 0, 256)
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", httpWResp.ContentLength.ToString)
Response.AddHeader("content-disposition", "filename=report.PDF")
While (count > 0)
'Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(read))
Dim str As String = New String(read, 0, count)
Response.Write(str) count = readstream.Read(read, 0, 256)
End While
'Response.Flush()
httpWResp.Close()
readstream.Close()
'Response.End()
This is the only code in my page. Can anyone help me out? Thanks
browser.. Can anyone tell what is wrong with this code? I've tried
everything
Thanks
Dim httpwreq As System.Net.HttpWebRequest =
CType(System.Net.HttpWebRequest.Create("http://lafdev2/ReportServeProxy/Migr
ationReport.pdf"), System.Net.HttpWebRequest)
Dim httpWResp As System.Net.HttpWebResponse =
CType(httpwreq.GetResponse, System.Net.HttpWebResponse)
Dim receiveStream As IO.Stream = httpWResp.GetResponseStream
Dim encode As System.Text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")
Dim readstream As System.IO.StreamReader = New
System.IO.StreamReader(receiveStream, encode)
Dim read(256) As Char
Dim count As Integer = readstream.Read(read, 0, 256)
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", httpWResp.ContentLength.ToString)
Response.AddHeader("content-disposition", "filename=report.PDF")
While (count > 0)
'Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(read))
Dim str As String = New String(read, 0, count)
Response.Write(str) count = readstream.Read(read, 0, 256)
End While
'Response.Flush()
httpWResp.Close()
readstream.Close()
'Response.End()
This is the only code in my page. Can anyone help me out? Thanks