Closed zuckerthoben closed 7 years ago
So RegisterForDispose is a static method that keeps track of all IDisposables until they can disposed safely?
Can you provide the full qualified namespace for the class where the method is defined and the signature of the method? I only found the source for the old asp.net stack (line 674 and 694)
The summary of the method says: "Registers an object for disposal by the host once the request has finished processing". So yeah, thats what it does. It hooks into OnCompleted and that is fired after sending the response. To me that looks like exactly what you want when working with IDisposable in a Web Api.
Will be part of release 0.33
The extension does not accept the ASP.Net core feature RegisterForDispose. In an ASP.Net core Web Api you get unnecessary overhead when directly disposing your IDisposables in your controller actions before the response. With RegisterForDispose the Middleware automatically disposes the registered ressources after finishing the request.
See: https://andrewlock.net/four-ways-to-dispose-idisposables-in-asp-net-core/