Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webclient bugging out or what?

Tags:

c#

.net

webclient

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:
"An unhandled exception of type 'System.Net.WebException' occurred in System.dll"

So I tried running only the webclient in a new project, downloading from a hardcoded url that I know is up like this.

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.

I could use some pointers. I'm new to .NET and have no idea how to troubleshoot this.

like image 883
Steinthor.palsson Avatar asked Jul 22 '26 05:07

Steinthor.palsson


1 Answers

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
  • Use Wireshark to see what's going on at the network level. That should show you if it's trying to connect, what it's getting back etc.
like image 79
Jon Skeet Avatar answered Jul 23 '26 20:07

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!