What is ServicePointManager.FindServicePoint used for?
Can someone explain what ServicePointManager.FindServicePoint is intended to be used for? I have been writing some code to work with proxies in C#, and have seen indicators that it might be useful in this respect, but can't see why or how. How is this class (ServicePointManager) or method (ServicePointManager.FindServicePoint) supposed to be used (or when)开发者_开发问答?
Thanks.
The ServicePointManager.FindServicePoint(...)
method will help you get the ServicePoint
object that you've been specified in the configuration file.
Let's say, this is your configuration file:
<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>
This code would retrieve the "http://www.microsoft.com" ServicePoint
:
ServicePoint sp1 = ServicePointManager.FindServicePoint(new Uri("http://www.microsoft.com"));
You can read all about it here.
精彩评论