File tree Expand file tree Collapse file tree 4 files changed +4
-6
lines changed
Expand file tree Collapse file tree 4 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ title: Use the IHttpClientFactory
33description : Learn how to use the HttpClient and IHttpClientFactory implementations with dependency injection in your .NET workloads.
44author : IEvangelist
55ms.author : dapine
6- ms.date : 08/13/2024
6+ ms.date : 05/06/2025
77---
88
99# IHttpClientFactory with .NET
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public sealed class TodoService(
1212 public async Task < Todo [ ] > GetUserTodosAsync ( int userId )
1313 {
1414 // Create the client
15- using HttpClient client = httpClientFactory . CreateClient ( ) ;
15+ HttpClient client = httpClientFactory . CreateClient ( ) ;
1616
1717 try
1818 {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public async Task<Todo[]> GetUserTodosAsync(int userId)
2323 {
2424 // Create the client
2525 string ? httpClientName = _configuration [ "TodoHttpClientName" ] ;
26- using HttpClient client = _httpClientFactory . CreateClient ( httpClientName ?? "" ) ;
26+ HttpClient client = _httpClientFactory . CreateClient ( httpClientName ?? "" ) ;
2727
2828 try
2929 {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ namespace TypedHttp.Example;
77
88public sealed class TodoService (
99 HttpClient httpClient ,
10- ILogger < TodoService > logger ) : IDisposable
10+ ILogger < TodoService > logger )
1111{
1212 public async Task < Todo [ ] > GetUserTodosAsync ( int userId )
1313 {
@@ -28,6 +28,4 @@ public async Task<Todo[]> GetUserTodosAsync(int userId)
2828
2929 return [ ] ;
3030 }
31-
32- public void Dispose ( ) => httpClient ? . Dispose ( ) ;
3331}
You can’t perform that action at this time.
0 commit comments