ASP.NET Core中的ServicePointManager

问题描述:

我试图将现有的类库代码转换为.NET Core类库。在一个static构造函数的代码,我有以下几点:ASP.NET Core中的ServicePointManager

ServicePointManager.DefaultConnectionLimit = 100; 
ServicePointManager.Expect100Continue = false; 

我做了一些搜索和ServicePointManager不再.NET提供的核心,并WinHttpHandler现在应该使用(ServicePointManager.DefaultConnectionLimit in .net core?)。

我的问题是究竟是什么ServicePointManager,什么是正在设置的属性?

WinHttpHandler不是static作为ServicePointManager所以我必须创建一个实例来设置这些属性?我是否需要更改所有的http调用以使用该实例?从HttpMessageHandler

WinHttpHandler继承,这样你就可以施工时把它作为一个参数,你HttpClient喜欢如下:

WinHttpHandler httpHandler = new WinHttpHandler(); 
httpHandler.SslProtocols = SslProtocols.Tls12; 

HttpClient client = new HttpClient(httpHandler); 

希望这有助于!