Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions xml/System.Net.Http/HttpClient.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Type Name="HttpClient" FullName="System.Net.Http.HttpClient">
<Type Name="HttpClient" FullName="System.Net.Http.HttpClient">
<TypeSignature Language="C#" Value="public class HttpClient : System.Net.Http.HttpMessageInvoker" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit HttpClient extends System.Net.Http.HttpMessageInvoker" />
<TypeSignature Language="DocId" Value="T:System.Net.Http.HttpClient" />
Expand Down Expand Up @@ -61,16 +61,27 @@
```csharp
public class GoodController : ApiController
{
// OK
private static readonly HttpClient HttpClient;

static GoodController()
{
HttpClient = new HttpClient();
}
}
```

```

```vb
Public Class GoodController
Inherits ApiController

Private Shared ReadOnly HttpClient As HttpClient

Shared Sub New()
HttpClient = New HttpClient()
End Sub
End Class
```

The <xref:System.Net.Http.HttpClient> is a high-level API that wraps the lower-level functionality available on each platform where it runs.

On each platform, <xref:System.Net.Http.HttpClient> tries to use the best available transport:
Expand Down Expand Up @@ -127,7 +138,8 @@ If this change is undesirable, you can configure your application to use the old

## Examples
[!code-csharp[System.Net.Http.HttpClient#1](~/samples/snippets/csharp/VS_Snippets_Misc/system.net.http.httpclient/cs/source.cs#1)]

[!code-vb[System.Net.Http.HttpClient#1](~/samples/snippets/visualbasic/VS_Snippets_Misc/system.net.http.httpclient/vb/source.vb#1)]

The preceding code example uses an `async Task Main()` entry point. That feature requires C# 7.1 or later.

]]></format>
Expand Down Expand Up @@ -157,17 +169,27 @@ If this change is undesirable, you can configure your application to use the old
```csharp
public class GoodController : ApiController
{
// OK
private static readonly HttpClient HttpClient;

static GoodController()
{
HttpClient = new HttpClient();
}
}

```

```

```vb
Public Class GoodController
Inherits ApiController

Private Shared ReadOnly HttpClient As HttpClient

Shared Sub New()
HttpClient = New HttpClient()
End Sub
End Class
```

]]></format>
</remarks>
</Docs>
Expand Down