简体   繁体   English

webclient烦恼或什么?

[英]webclient bugging out or what?

hi
I ran my project yesterday just fine, but today when I ran the same code it hangs on WebClient.DownloadFile() and eventually times out with this error message: 我昨天运行我的项目很好,但今天当我运行相同的代码时,它挂起在WebClient.DownloadFile()上,并最终超时出现此错误消息:
"An unhandled exception of type 'System.Net.WebException' occurred in System.dll" “System.dll中发生了'System.Net.WebException'类型的未处理异常”

So I tried running only the webclient in a new project, downloading from a hardcoded url that I know is up like this. 所以我尝试在一个新项目中只运行webclient,从一个我知道的硬编码网址下载。

static void Main(string[] args)
    {
        WebClient client = new WebClient();
        client.DownloadFile("http://www.ashersarlin.com/cartoons/officerap2.gif", "pic.gif");
    }

Same thing happens. 同样的事情发生了 It creates an empty file "pic.gif" but times out eventually. 它会创建一个空文件“pic.gif”但最终会超时。

I could use some pointers. 我可以使用一些指针。 I'm new to .NET and have no idea how to troubleshoot this. 我是.NET的新手,不知道如何解决这个问题。

Your exact code works for me... 你的确切代码对我有用......

Perhaps your default proxy is messed up? 也许你的默认代理搞砸了?

Suggestions: 建议:

  • Print out the detail of the WebException - it may give more hints 打印出WebException的细节 - 它可能会提供更多提示
  • Use Wireshark to see what's going on at the network level. 使用Wireshark查看网络级别的情况。 That should show you if it's trying to connect, what it's getting back etc. 这应该会告诉你它是否正在尝试连接,它是什么回来等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM