我正在使用 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
我不知道该错误是什么意思,也不知道如何解决。有什么猜测吗?