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.
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.
精彩评论