From e2fba219d880adcbb3c023342e57279389b6d961 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:16:34 -0500 Subject: [PATCH 1/4] Fix link for using declaration --- aspnetcore/blazor/call-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/call-web-api.md b/aspnetcore/blazor/call-web-api.md index a8698f9355b0..f13d72e5887d 100644 --- a/aspnetcore/blazor/call-web-api.md +++ b/aspnetcore/blazor/call-web-api.md @@ -358,7 +358,7 @@ The solution includes a demonstration of obtaining weather data securely via an ## Disposal of `HttpRequestMessage`, `HttpResponseMessage`, and `HttpClient` -An without a body doesn't require explicit disposal with a [`using` declaration (C# 8 or later)](/dotnet/csharp/language-reference/proposals/csharp-8.0/using) or a [`using` block (all C# releases)](/dotnet/csharp/language-reference/keywords/using), but we recommend disposing with every use for the following reasons: +An without a body doesn't require explicit disposal with a [`using` declaration (C# 8 or later)](/dotnet/csharp/language-reference/keywords/using-directive) or a [`using` block (all C# releases)](/dotnet/csharp/language-reference/keywords/using), but we recommend disposing with every use for the following reasons: * To gain a performance improvement by avoiding finalizers. * It hardens the code for the future in case a request body is ever added to an that didn't initially have one. From fd4d3110c96c41bd35e72cd0121a003e20b0a5ef Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:36:31 -0500 Subject: [PATCH 2/4] Update aspnetcore/blazor/call-web-api.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- aspnetcore/blazor/call-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/call-web-api.md b/aspnetcore/blazor/call-web-api.md index f13d72e5887d..05548c48019e 100644 --- a/aspnetcore/blazor/call-web-api.md +++ b/aspnetcore/blazor/call-web-api.md @@ -358,7 +358,7 @@ The solution includes a demonstration of obtaining weather data securely via an ## Disposal of `HttpRequestMessage`, `HttpResponseMessage`, and `HttpClient` -An without a body doesn't require explicit disposal with a [`using` declaration (C# 8 or later)](/dotnet/csharp/language-reference/keywords/using-directive) or a [`using` block (all C# releases)](/dotnet/csharp/language-reference/keywords/using), but we recommend disposing with every use for the following reasons: +An without a body doesn't require explicit disposal with a `using` declaration (C# 8 or later, example: `using var request = new HttpRequestMessage(...);`) or a [`using` block (all C# releases, example: `using (var request = new HttpRequestMessage(...)) { ... }`)](/dotnet/csharp/language-reference/keywords/using), but we recommend disposing with every use for the following reasons: * To gain a performance improvement by avoiding finalizers. * It hardens the code for the future in case a request body is ever added to an that didn't initially have one. From eb3de4d802a6edead41219b3d07221db99b1c3f3 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:47:22 -0500 Subject: [PATCH 3/4] Updates --- aspnetcore/blazor/call-web-api.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/aspnetcore/blazor/call-web-api.md b/aspnetcore/blazor/call-web-api.md index 05548c48019e..bc0db326dea2 100644 --- a/aspnetcore/blazor/call-web-api.md +++ b/aspnetcore/blazor/call-web-api.md @@ -358,7 +358,24 @@ The solution includes a demonstration of obtaining weather data securely via an ## Disposal of `HttpRequestMessage`, `HttpResponseMessage`, and `HttpClient` -An without a body doesn't require explicit disposal with a `using` declaration (C# 8 or later, example: `using var request = new HttpRequestMessage(...);`) or a [`using` block (all C# releases, example: `using (var request = new HttpRequestMessage(...)) { ... }`)](/dotnet/csharp/language-reference/keywords/using), but we recommend disposing with every use for the following reasons: +An without a body doesn't require explicit disposal. However, you can dispose of it with either of the following patterns: + +* `using` declaration (C# 8 or later): + + ```csharp + using var request = new HttpRequestMessage(...); + ``` + +* [`using` block (all C# releases)](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/using): + + ```csharp + using (var request = new HttpRequestMessage(...)) + { + ... + } + ``` + +We recommend disposing of every with every use for the following reasons: * To gain a performance improvement by avoiding finalizers. * It hardens the code for the future in case a request body is ever added to an that didn't initially have one. From e1aa65ad13a454f8dd6a5fe2690ae8838d0d2bce Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:50:42 -0500 Subject: [PATCH 4/4] Update aspnetcore/blazor/call-web-api.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- aspnetcore/blazor/call-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/call-web-api.md b/aspnetcore/blazor/call-web-api.md index bc0db326dea2..d8c899decc09 100644 --- a/aspnetcore/blazor/call-web-api.md +++ b/aspnetcore/blazor/call-web-api.md @@ -366,7 +366,7 @@ An without a body doesn't require expl using var request = new HttpRequestMessage(...); ``` -* [`using` block (all C# releases)](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/using): +* [`using` block (all C# releases)](/dotnet/csharp/language-reference/keywords/using): ```csharp using (var request = new HttpRequestMessage(...))