共用方式為


ServicePointManager 類別

定義

警告

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.

管理 ServicePoint 物件的集合。

public ref class ServicePointManager
public class ServicePointManager
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public class ServicePointManager
type ServicePointManager = class
[<System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ServicePointManager = class
Public Class ServicePointManager
繼承
ServicePointManager
屬性

範例

下列程式代碼範例會建立 ServicePoint 物件,以便連線到 URI www.contoso.com

Uri^ myUri = gcnew Uri( "http://www.contoso.com/" );
ServicePoint^ mySP = ServicePointManager::FindServicePoint( myUri );
Uri myUri = new Uri("http://www.contoso.com/");

ServicePoint mySP = ServicePointManager.FindServicePoint(myUri);
Dim myUri As New Uri("http://www.contoso.com/")
       
Dim mySP As ServicePoint = ServicePointManager.FindServicePoint(myUri)

備註

ServicePointManager 是靜態類別,可用來建立、維護和刪除 ServicePoint 類別的實例。

當應用程式透過 ServicePointManager 物件要求連線到因特網資源統一資源標識碼 (URI)時,ServicePointManager 會傳回 ServicePoint 物件,其中包含 URI 所識別主機和配置的連接資訊。 如果該主機和配置有現有的 ServicePoint 物件,ServicePointManager 對象會傳回現有的 ServicePoint 物件;否則,ServicePointManager 物件會建立新的 ServicePoint 物件。

.NET Framework 4.6 包含新的安全性功能,可封鎖連線不安全的加密和哈希演算法。 透過 API 使用 TLS/SSL 的應用程式,例如 HttpClientHttpWebRequestFtpWebRequestSmtpClientSslStream等,並以 .NET Framework 4.6 為目標,預設會取得更安全的行為。

開發人員可能會想要退出退出此行為,以維持與其現有 SSL3 服務或 TLS w/ RC4 服務的互操作性。 本文 說明如何修改程序代碼,以便停用新的行為。

重要

不建議您將 ServicePointManager 類別用於新的開發。 請改用 System.Net.Http.HttpClient 類別。

欄位

DefaultNonPersistentConnectionLimit
已淘汰.

連線到 HTTP/1.0 或更新版本的伺服器之 ServicePoint 物件上允許的預設非持續性連線數目 。。 此欄位是常數,但不再作為 .NET Framework 2.0 使用。

DefaultPersistentConnectionLimit
已淘汰.

連線到 HTTP/1.1 或更新版本的伺服器之 ServicePoint 物件上允許的預設持續性連接數目 。。 這個欄位是常數,如果尚未直接或透過組態設定 DefaultConnectionLimit 屬性值,則此欄位是常數,用來初始化 DefaultConnectionLimit 屬性。

屬性

CertificatePolicy
已淘汰.

取得或設定伺服器證書的原則。

CheckCertificateRevocationList
已淘汰.

取得或設定 Boolean 值,指出是否已根據證書頒發機構單位撤銷清單檢查憑證。

DefaultConnectionLimit
已淘汰.

取得或設定 ServicePoint 物件允許的並行連接數目上限。

DnsRefreshTimeout
已淘汰.

取得或設定值,這個值表示功能變數名稱服務 (DNS) 解析視為有效的時間長度。

EnableDnsRoundRobin
已淘汰.

取得或設定值,這個值表示功能變數名稱服務 (DNS) 解析是否會在適用的因特網通訊協定 (IP) 位址之間輪替。

EncryptionPolicy
已淘汰.

取得這個 ServicePointManager 實例的 EncryptionPolicy

Expect100Continue
已淘汰.

取得或設定 Boolean 值,判斷是否使用 100-Continue 行為。

MaxServicePointIdleTime
已淘汰.

取得或設定 ServicePoint 物件的空閒時間上限。

MaxServicePoints
已淘汰.

取得或設定隨時要維護之 ServicePoint 物件數目上限。

ReusePort
已淘汰.

將此屬性值設定為 true 會導致來自 HttpWebRequest 的所有輸出 TCP 連線使用套接字上的原生套接字選項SO_REUSE_UNICASTPORT。 這會導致共用基礎傳出埠。 這適用於在短時間內進行大量連出連線的情況,而且應用程式可能會耗盡埠。

SecurityProtocol
已淘汰.

取得或設定由 ServicePointManager 物件所管理之 ServicePoint 物件所使用的安全性通訊協定。

ServerCertificateValidationCallback
已淘汰.

取得或設定要驗證伺服器證書的回呼。

UseNagleAlgorithm
已淘汰.

判斷 Nagle 演算法是否由這個 ServicePointManager 物件所管理的服務點使用。

方法

Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindServicePoint(String, IWebProxy)
已淘汰.

尋找現有的 ServicePoint 物件,或建立新的 ServicePoint 物件來管理與指定統一資源標識元 (URI) 的通訊。

FindServicePoint(Uri)
已淘汰.

尋找現有的 ServicePoint 物件,或建立新的 ServicePoint 物件來管理與指定之 Uri 對象的通訊。

FindServicePoint(Uri, IWebProxy)
已淘汰.

尋找現有的 ServicePoint 物件,或建立新的 ServicePoint 物件來管理與指定之 Uri 對象的通訊。

GetHashCode()
已淘汰.

做為預設哈希函式。

(繼承來源 Object)
GetType()
已淘汰.

取得目前實例的 Type

(繼承來源 Object)
MemberwiseClone()
已淘汰.

建立目前 Object的淺層複本。

(繼承來源 Object)
SetTcpKeepAlive(Boolean, Int32, Int32)
已淘汰.

啟用或停用 TCP 連線上的keep-alive 選項。

ToString()
已淘汰.

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於

另請參閱