0
我正在使用Webclient类下载网站HTML。代码很简单:无法从传输连接读取数据:建立的连接被主机中的软件中止
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
string web = client.DownloadString(url);
但是有时我会得到这个错误消息,我不能再现。它似乎随机发生:
System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
我不知道这个错误意味着什么,或者我可以如何解决它。任何猜测?
你是否试过在使用语句中包装WebClient? (不知道是否WebClient是一次性的或不...) – 2012-07-12 18:30:47
可能重复[建立的连接被您的主机中的软件中止](http://stackoverflow.com/questions/1608431/an-established-connection-被软件在你的主机中断) – David 2012-07-12 18:31:59
@RobertH我处理这个类,我忘了粘贴这部分代码。 – broke 2012-07-12 18:39:13