G
Guest
Hi,
I am trying to display a pdf file on the web. It is working fine but the
Page_Load method is running twice before displaying the page. Here is the
code that I am using
Private Sub ReadPdfFile(ByVal strFilepath As String)
'Create WebClient Object
Dim objWebClient As New WebClient
'Create Byte Array to download data
Dim byteBuffer() As Byte = objWebClient.DownloadData(strFilepath)
'Read Data
If Not byteBuffer Is Nothing Then
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", byteBuffer.Length.ToString())
'Response.ClearHeaders()
Response.BinaryWrite(byteBuffer)
Response.End()
End If
End Sub
I am thinking it is due to Response object. How could I solve this?
Thanks,
Sridhar.
I am trying to display a pdf file on the web. It is working fine but the
Page_Load method is running twice before displaying the page. Here is the
code that I am using
Private Sub ReadPdfFile(ByVal strFilepath As String)
'Create WebClient Object
Dim objWebClient As New WebClient
'Create Byte Array to download data
Dim byteBuffer() As Byte = objWebClient.DownloadData(strFilepath)
'Read Data
If Not byteBuffer Is Nothing Then
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", byteBuffer.Length.ToString())
'Response.ClearHeaders()
Response.BinaryWrite(byteBuffer)
Response.End()
End If
End Sub
I am thinking it is due to Response object. How could I solve this?
Thanks,
Sridhar.