Provides the default message handler used by HttpClient in .NET Core 2.1 and later.
public ref class SocketsHttpHandler sealed : System::Net::Http::HttpMessageHandler
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public sealed class SocketsHttpHandler : System.Net.Http.HttpMessageHandler
public sealed class SocketsHttpHandler : System.Net.Http.HttpMessageHandler
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type SocketsHttpHandler = class
inherit HttpMessageHandler
type SocketsHttpHandler = class
inherit HttpMessageHandler
Public NotInheritable Class SocketsHttpHandler
Inherits HttpMessageHandler
Starting with .NET Core 2.1, the SocketsHttpHandler
class provides the implementation used by higher-level HTTP networking classes such as HttpClient. The use of SocketsHttpHandler
offers a number of advantages:
A significant performance improvement when compared with the previous implementation.
The elimination of platform dependencies, which simplifies deployment and servicing. For example, libcurl
is no longer a dependency on .NET Core for macOS and .NET Core for Linux.
Consistent behavior across all .NET platforms.
If this change is undesirable and you are on .NET Core 2.1-3.1, you can configure your application to use the older System.Net.Http.HttpClientHandler class instead in a number of ways:
By calling the AppContext.SetSwitch method as follows:
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", False)
By defining the System.Net.Http.UseSocketsHttpHandler
switch in the .netcore.runtimeconfig.json configuration file:
"runtimeOptions": {
"configProperties": {
"System.Net.Http.UseSocketsHttpHandler": false
}
}
By defining an environment variable named DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER
and setting it to either false
or 0.
These configuration options are not available starting with .NET 5.
Constructors Properties MethodsCollaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4