I am writing a web page in VB 2005 (using .NET 2.0). I have PDF files stored in a database (also on the web server), and the user can request to view them. When they do, I pull the file out of the database and save it to the hard drive on my web server. I am trying to create a session variable of the files I create for a user during their session.
What I would like to do is keep track of the filenames so I can delete them at the end of the user's session. The reasons are twofold: 1. disk space is at a premium, and 2. this site needs to be secure, so I don't want these files "living" for very long outside of the database. I was thinking this would require a string array of the file names, but have been very confused as to variable instantiation in the Global.asax file. How do session variables work? I've googled this topic some, but I cannot really make sense of what I've seen on the web. No one seems to describe how to declare a variable and later use it. Or maybe they have and I just don't get it. Help? Please?
Option #2: Another method I thought of that might work is if I can load the PDF into a MemoryStream (or something similar) and stream this directly to the web browser rather than saving the file then directing the web browser to the file. It seems that this would be much more secure and I wouldn't have to "clean up" after each user session. I am new to web coding, so I am not sure how/if this can be done. I WOULD PROBABLY PREFER THIS METHOD IF IT IS POSSIBLE.
Thanks for any help.