什么是ServicePointManager.FindServicePoint用于?

时间:2009-12-18 16:38:38

标签: c# .net wcf proxy

有人可以解释一下ServicePointManager.FindServicePoint的用途吗?我一直在编写一些代码来处理C#中的代理,并且已经看到它在这方面可能有用的指标,但看不出原因或方法。该类(ServicePointManager)或方法(ServicePointManager.FindServicePoint)应该如何使用(或何时)?

感谢。

1 个答案:

答案 0 :(得分:3)

ServicePointManager.FindServicePoint(...)方法将帮助您获取在配置文件中指定的ServicePoint对象。

假设这是您的配置文件:

<configuration>
 <system.net>
  <connectionManagement>
   <add address="http://www.contoso.com" maxconnection="2" />
   <add address="192.168.1.2" maxconnection="4" />
   <add address="*" maxconnection="1" />
  </connectionManagement>
 </system.net>
</configuration>

此代码将检索“http://www.microsoft.comServicePoint

ServicePoint sp1 = ServicePointManager.FindServicePoint(new Uri("http://www.microsoft.com"));

您可以阅读所有相关内容here