ServicePointManager 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
管理 ServicePoint 对象集合。
public ref class ServicePointManager
public class ServicePointManager
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(如 HttpClient、、HttpWebRequest、FtpWebRequestSmtpClient、 SslStream等)使用 TLS/SSL 并面向 .NET Framework 4.6 的应用程序会获得更安全的行为。
开发人员可能需要选择退出此行为,以保持与其现有 SSL3 服务或 TLS(含 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 |
将此属性值设置为 |
SecurityProtocol |
获取或设置由 ServicePointManager 对象管理的 ServicePoint 对象所使用的安全协议。 |
ServerCertificateValidationCallback |
获取或设置用于验证服务器证书的回调。 |
UseNagleAlgorithm |
确定由此 ServicePointManager 对象管理的服务点是否使用 Nagle 算法。 |
方法
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) |
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈