【C#】进行HTTP请求需要设置的参数

.Net中进行HTTP请求非常方便,会经常使用

WebRequest,HttpWebRequest,WebClient

如果在网络环境不好的情况下进行大量并发操作,很可能会导致性能急剧下降

通常情况下,在程序开始时设置几个参数即可:

ServicePointManager.DefaultConnectionLimit = 20;
WebRequest.DefaultWebProxy
= null;

ServicePointManager.DefaultConnectionLimit 参考这里

WebRequest.DefaultWebProxy 参考这里

这两个设置都是对已经实例化的ServicePoint是无效的。

原文地址:https://www.cnblogs.com/Aimeast/p/1963650.html