Lets imagine a class
class Foo: IDisposable
{
Dispose()
{
//Dispose of nonmanged resources.
}
}
Let image that a use case exist for putting it into HttpContext.Items. It doesn’t automatically raise errors when you add an object that implement IDisposable (and who knows, maybe the answer is that it should)
What event(s) do I need to hook into to dispose of that item?
Lets also assume that using blocks are not available as the object gets used into two different method blocks.
Per @Jaroslav Jandek, I think hooking into
Application_EndRequestin global.asax would work just fine. You can do a simple check to see if the item is preset inHttpContext.Itemsand if it is then dispose of it.