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 对象请求连接到 Internet 资源统一资源标识符(URI)时,ServicePointManager 将返回一个 ServicePoint 对象,该对象包含 URI 标识的主机和方案的连接信息。 如果该主机和方案存在现有 ServicePoint 对象,则 ServicePointManager 对象返回现有 ServicePoint 对象;否则,ServicePointManager 对象将创建新的 ServicePoint 对象。

.NET Framework 4.6 包括一项新的安全功能,用于阻止连接的不安全密码和哈希算法。 通过 API(如 HttpClientHttpWebRequestFtpWebRequestSmtpClientSslStream等)使用 TLS/SSL 的应用程序默认获取更安全的行为。

开发人员可能希望选择退出此行为,以便保持与其现有 SSL3 服务或 TLS w/ RC4 服务的互操作性。 本文 介绍如何修改代码,以便禁用新行为。

重要

不建议使用 ServicePointManager 类进行新开发。 请改用 System.Net.Http.HttpClient 类。

字段

DefaultNonPersistentConnectionLimit
已过时.

连接到 HTTP/1.0 或更高版本服务器的 ServicePoint 对象上允许的默认非持久性连接数(4)。 此字段是常量,但不再用作 .NET Framework 2.0。

DefaultPersistentConnectionLimit
已过时.

连接到 HTTP/1.1 或更高版本服务器的 ServicePoint 对象上允许的默认持久性连接数(2)。 此字段是常量,用于在尚未直接或通过配置设置 DefaultConnectionLimit 属性的值时初始化 DefaultConnectionLimit 属性。

属性

CertificatePolicy
已过时.

获取或设置服务器证书的策略。

CheckCertificateRevocationList
已过时.

获取或设置一个 Boolean 值,该值指示是否根据证书颁发机构吊销列表检查证书。

DefaultConnectionLimit
已过时.

获取或设置 ServicePoint 对象允许的最大并发连接数。

DnsRefreshTimeout
已过时.

获取或设置一个值,该值指示域名服务 (DNS) 解析被视为有效的时长。

EnableDnsRoundRobin
已过时.

获取或设置一个值,该值指示域名服务(DNS)解析是否在适用的 Internet 协议(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 连接的保持活动选项。

ToString()
已过时.

返回一个表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅