开发者

Will My Dispose Methods Get Called at End of ASP.NET Request

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜