Skip to content

Commit 041e196

Browse files
authored
Fix link for using declaration (#36309)
1 parent e8eb63b commit 041e196

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

aspnetcore/blazor/call-web-api.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,24 @@ The solution includes a demonstration of obtaining weather data securely via an
358358
359359
## Disposal of `HttpRequestMessage`, `HttpResponseMessage`, and `HttpClient`
360360
361-
An <xref:System.Net.Http.HttpRequestMessage> 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:
361+
An <xref:System.Net.Http.HttpRequestMessage> without a body doesn't require explicit disposal. However, you can dispose of it with either of the following patterns:
362+
363+
* `using` declaration (C# 8 or later):
364+
365+
```csharp
366+
using var request = new HttpRequestMessage(...);
367+
```
368+
369+
* [`using` block (all C# releases)](/dotnet/csharp/language-reference/keywords/using):
370+
371+
```csharp
372+
using (var request = new HttpRequestMessage(...))
373+
{
374+
...
375+
}
376+
```
377+
378+
We recommend disposing of every <xref:System.Net.Http.HttpRequestMessage> with every use for the following reasons:
362379
363380
* To gain a performance improvement by avoiding finalizers.
364381
* It hardens the code for the future in case a request body is ever added to an <xref:System.Net.Http.HttpRequestMessage> that didn't initially have one.

0 commit comments

Comments
 (0)