I have an aspx page which houses an iframe. When a button is clicked, a WCF is called to produce a PDF which is read into a byte array. I was storing the byte array in a Globals.vb file like this:
Public Shared PDF_Data as Byte()
The global was loaded from the parent aspx page like this:
PDF_Data = MyWCF.Create_PDF_File(SomeVariable)
After that, the iFrame’s src was set to a blank aspx page, which had the following code in the page_load event:
'Write the PDF binary data to the screen (viewer)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(Globals.PDF_Data.ToArray)
However, realizing that this application will have several users who will get different PDF documents, I have learned that this is not the way to go. My shared variable would be accessible to all users, a big no-no.
However, I am stumped as to how I’m going to store the byte array and make it available to a child aspx page from it’s parent.
Any ideas would be greatly appreciated!
Thanks,
Jason
The shared variable is definitely not the way to go. I took over a project that used that technique and there were slews of issues with one user getting another users data. You should either use Session, which in itself can be an issue.
One suggestion that I’ve used saving the byte data to a database with a key and passing that key to the iframe within the URL with the query string. In that case, you should have a way to clear out the past records from the db before it takes up too much space. Depending on if this PDF document is supposed to be secure, this will open up so that the PDF would be accessible by people fiddling with the query string.
Another suggestion, passing it as B64 encoded POST data. Those are a couple suggestions.