【问题标题】:What is ServicePointManager.FindServicePoint used for?ServicePointManager.FindServicePoint 的用途是什么?
【发布时间】:2009-12-18 16:38:38
【问题描述】:

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

谢谢。

【问题讨论】:

    标签: c# .net wcf proxy


    【解决方案1】:

    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

    【讨论】:

      猜你喜欢
      • 2012-06-03
      • 1970-01-01
      • 2010-09-27
      • 2011-12-17
      • 2010-11-21
      • 1970-01-01
      • 2019-05-31
      • 2021-07-19
      相关资源
      最近更新 更多