AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Disposing of Dependencies Injected into Custom DelegatingHandlers
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.
- ID: 881cef77-11ef-ac11-06d0-0996a1ccfa1b
- Version Independent ID: 3d356334-e672-7e8b-1fef-7944ebee99eb
- Content: Make HTTP requests using IHttpClientFactory in ASP.NET Core
- Content Source: aspnetcore/fundamentals/http-requests.md
- Product: aspnet-core
- Technology: aspnetcore-fundamentals
- GitHub Login: @stevejgordon
- Microsoft Alias: scaddie
Moved to master issue: Make HTTP requests using IHttpClientFactory #16641