Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
'declare variables
Dim uuid As Guid
Dim ByteArray As Byte()
'if it's not there, bail
If Request("uuid") Is Nothing Then
Response.Redirect("~/default2.aspx")
End If
'get the uuid
uuid = New Guid(Request("uuid"))
'query the database and get a class that contains the IMAGE field
Dim oFPDocument As New DynData.FPDocument(uuid, App.ConnectionString)
'if the data access failed, bail
If Not oFPDocument.isPopulated Then
Response.Redirect("~/default2.aspx")
End If
'populate our byte array
ByteArray = oFPDocument.ImageBLOB
'output the PDF to the browser
Response.Clear()
Response.Buffer = True
Response.AddHeader("Content-Length", ByteArray.Length.ToString())
Response.AddHeader("Content-Disposition", "inline; filename=PDF")
Response.AddHeader("Expires", "0")
Response.AddHeader("Pragma", "cache")
Response.AddHeader("Cache-Control", "private")
Response.ContentType = "application/pdf"
Response.BinaryWrite(ByteArray)
Response.Flush()
Catch ex As ThreadAbortException
'the response.redirects throw an error, but it's not really an error
Catch ex As Exception
'this is really an error, so handle it
ErrorHandler.globalErrorHandler(ex, False)
End Try
End Sub