How do I dispose my filestream when implementing a file download in ASP.NET?
I have a class DocumentGenerator which wraps a MemoryStream. So I have implemented IDisposable on the class.
I have a class DocumentGenerator which wraps a MemoryStream. So I have implemented IDisposable on the class.
In ASP.NET if items are left in the session state that Implement IDisposable but are never specifically removed and disposed by the application when the session expires will Dispose be called on the objects that any code in Dipose() will execute?
I was wondering if there was some sort of cheat sheet for which objects go well with the using statement… SQLConnection, MemoryStream, etc.
Given that the Control class implements IDisposable, I would think that ASP.Net is at least capable of triggering a Dispose cascade as the Page finishes it’s life-cycle on the way out the door to the browser?
Suppose I have the following: