AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Disposing of Dependencies Injected into Custom DelegatingHandlers

Open JoeBrockhaus opened this issue 6 years ago • 1 comments

In the preceding code, the ValidateHeaderHandler is registered with DI. The IHttpClientFactory creates a separate DI scope for each handler. Handlers can depend upon services of any scope. Services that handlers depend upon are disposed when the handler is disposed.

Is the text in bold accurate? Are all dependencies disposed of, or only those in the same (new) scope? (ie: Services from parent scopes should not be disposed-of, correct? For instance, in the case of injecting a CacheProvider.)


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

JoeBrockhaus avatar Apr 29 '20 20:04 JoeBrockhaus

Moved to master issue: Make HTTP requests using IHttpClientFactory #16641

Rick-Anderson avatar Apr 29 '20 21:04 Rick-Anderson