asp.net - Who's responsible for disposing HttpPostedFile.InputStream - and when? -
When you receive an uploaded file in asp.net, you usually do this HttpPostedFile
objects. The received data is made available through the HttpPostedFile.InputStream
. It is a property that has inspired me to believe that I do not have to settle myself, although in the documentation it has never been told who is responsible for discharging the stream, and if it is by ASP.net Framework, When does this (say, can I save the stream in the session, would I prefer?).
Now, I have not received this many files, and I have not run into problems to not dispose of this special stream, but for cleaning - does anyone know what the design contract is here is?
With my experience working with it, I will say that as soon as the request processing is complete, it will continue is done. One example is that I had to throw a ball in the air. If I will not catch it and it kills the ground ... it is settled if I catch it and do something with it ... and then leave it, it is settled. It does not drag you to play in the next request!
While addressing the issue of storage in the session, I would say Noo OO! If you have to keep it around for a while, then it must be written in the file system. When you need it, it must be reconnected as a stream and play with it. Storing a file stream in session (possibly as a byte array?) Seems like a heavy waste of your session (memory) resources.
Comments
Post a Comment