2016-09-18 57 views
9

我試圖將現有的類庫代碼轉換爲.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

回答

8

WinHttpHandler繼承,這樣你就可以施工時把它作爲一個參數,你HttpClient喜歡如下:

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

HttpClient client = new HttpClient(httpHandler); 

希望這有助於!