views:

420

answers:

2

I'm using ASP.NET WebClient.DownloadFile(url) to obtain images from the Image Servers of several of our clients. The 'url' is usually simple, like "http://somewhere.com/images/image01.jpg".

This works great for 99% of our clients. But one is giving me a "An existing connection was forcibly closed by the remote host". Every time.

I tried using DownloadData() instead, same issue. And I can get the image via a browser, but not with WebClient.

Does anyone have any recommendations?

David

A: 

It might be worth using something like the HttpFox FireFox addon to see exactly what the server is doing when you request that file as it might be doing something "odd" like setting/reading a tracking cookie before it will download (just a random example).

It won't fix the problem, but it might give you an idea why the WebClient isn't handling it.

Steven Robbins
+1  A: 

Some servers will look for specific user-agent strings to prevent bots and other leeching sites from downloading images. Check out the user-agent that you're setting in webclient.

Sijin