I know you have cut'n'pasted, etc. But humor me (us):
What happens if you don't reduce the file size (Highlighted in red, above). ie Read and Send the Last byte of the PDF?
Also, I know very little about ASP.NET security contexts, etc, so I might be stearing you in the wrong direction here. But what's the ownership of aspx file(s) - ie compare the owners of both aspx files/resources (Security tab, advance, etc).
Edit: I just read the VB.NET doco, and the ReDim was right (changed from VB6), but FileStream.Read is expecting a count. I'd probably change the ReDim anyway, just from a consisency/maintainability point of view, though.
Oh, and I'm assuming that the posted code is a cut-down version, without the error/sanity checking...
A valid point.
You found a legitimate and glaring error on not reading in the last byte.
Unfortunately, changing it has no effect. It still does not work in the new page, but works in the old page (I changed both).
How it has worked for years is a small miracle maybe. If the last byte is always 00, which I am seeing consistently in many PDFs, then maybe it has been sliding by for that reason.
The security contexts on both files are identical.
I have included only the code that does the lifting for simplicity. I did not include the Try-Catch stuff.