I see no one mentioned this yet, but besides implementing IDisposable in your type, you can also use {HttpContext}.Response.RegisterForDispose(objectToDispose). Typically this is used to register an object at the start of a request (such as a controller action) to be disposed when the request ends.