抛出尝试通过代码检查互联网连接时出现操作超时错误,在另一台电脑上运行良好



我正在使用此代码检查C#代码中的互联网连接。。

WebClient工作站=新WebClient((;

byte[]数据=工作站。下载数据("http://www.google.com"(;

它在另一台电脑上运行良好(每次都返回结果(,但在我的电脑(windows 7,64位(上,有时会显示"操作超时错误"(System.Net.WebException(。这是电脑特有的问题吗,在不同的环境中尝试过,但没有得到任何线索。。

终于找到了解决方案。。

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
ServicePointManager.DefaultConnectionLimit = 9999;

相关内容