Run-time configuration options for networking
HTTP/2 protocol
Configures whether support for the HTTP/2 protocol is enabled.
Introduced in .NET Core 3.0.
.NET Core 3.0 only: If you omit this setting, support for the HTTP/2 protocol is disabled. This is equivalent to setting the value to
false
..NET Core 3.1 and .NET 5+: If you omit this setting, support for the HTTP/2 protocol is enabled. This is equivalent to setting the value to
true
.
Setting name | Values | |
---|---|---|
runtimeconfig.json | System.Net.Http.SocketsHttpHandler.Http2Support |
false - disabledtrue - enabled |
Environment variable | DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2SUPPORT |
0 - disabled1 - enabled |
UseSocketsHttpHandler
Configures whether System.Net.Http.HttpClientHandler uses System.Net.Http.SocketsHttpHandler or older HTTP protocol stacks (WinHttpHandler on Windows and
CurlHandler
, an internal class implemented on top of libcurl, on Linux).Note
You may be using high-level networking APIs instead of directly instantiating the HttpClientHandler class. This setting also affects which HTTP protocol stack is used by high-level networking APIs, including HttpClient and HttpClientFactory.
If you omit this setting, HttpClientHandler uses SocketsHttpHandler. This is equivalent to setting the value to
true
.You can configure this setting programmatically by calling the AppContext.SetSwitch method.
Setting name | Values | |
---|---|---|
runtimeconfig.json | System.Net.Http.UseSocketsHttpHandler |
true - enables the use of SocketsHttpHandlerfalse - enables the use of WinHttpHandler on Windows or libcurl on Linux |
Environment variable | DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER |
1 - enables the use of SocketsHttpHandler0 - enables the use of WinHttpHandler on Windows or libcurl on Linux |
Note
Starting in .NET 5, the System.Net.Http.UseSocketsHttpHandler
setting is no longer available.
Latin1 headers (.NET Core 3.1 only)
This switch allows relaxing the HTTP header validation, enabling SocketsHttpHandler to send ISO-8859-1 (Latin-1) encoded characters in headers.
If you omit this setting, an attempt to send a non-ASCII character will result in HttpRequestException. This is equivalent to setting the value to
false
.
Setting name | Values | |
---|---|---|
runtimeconfig.json | System.Net.Http.SocketsHttpHandler.AllowLatin1Headers |
false - disabledtrue - enabled |
Environment variable | DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_ALLOWLATIN1HEADERS |
0 - disabled1 - enabled |
Note
This option is only available in .NET Core 3.1 since version 3.1.9, and not in previous or later versions. In .NET 5 we recommend using RequestHeaderEncodingSelector.