I am using VB.NET to write a pdf file directly to the browser, which opens it right away replacing the content in a current window. I am trying to do is set a parameter which will cause binarywrite in a new tab / window.
' Set the appropriate ContentType.
Response.ContentType = "Application/pdf"
' Write file directly to browser.
Response.BinaryWrite(binaryData)
Response.End()
There is has to be something that I can set which will cause this to write binary PDF in a new window. Like Response.Target = "_blank" ?????
First, create an additional page named "PDF.aspx" or whatever you would like it called.
Second, in your page, store your "binarydata" variable in a session.
Session("binaryData") = binarydata
And tell it to go to your new page.
Response.Redirect("PDF.aspx")
Third, go to your PDF.aspx code behind page and put the following:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Response.ContentType = "Application/pdf"
Response.BinaryWrite(Session("binaryData"))
Response.End()
Catch ex As Exception
Throw ex
End Try
End Sub
That should produce the result you want. :)