3

I have a lightweight class I use to keep keep track of who the user is in an ASP.NET MVC web request. It retrieves a dictionary from application cache and reads and modifies some values, and at the end of each method where the cached dictionary is accessed, inserts the dictionary back into cache.

I would like to just be able to modify the dictionary, and have it inserted back into cache at the end of the web request by implementing IDisposable. Will ASP.NET call Dispose on every object that was created in the course of the request, or do I need to handle this manually in the application's end request event.

1 Answer 1

4

No, ASP.NET will not call the Dispose method on any instance. You will need to handle this either with a using statement or by manually calling Dispose on the instance.

2
  • Thanks. Can you tell me if a dictionary retrieved from the cache is a reference or a copy? Because if it's a reference, then I don't even need to insert if back, right? Nov 29, 2009 at 13:14
  • OK, the reference thing was a silly question, of course it is a reference and there's no need to insert it back. Nov 29, 2009 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.