WebClient.DownloadData returns 404 file not found. What causes this?
I can open an image from WebClient.DownloadData
but for some urls which am able to open via web-browser, can't able to get image byte array if used via WebClient.Downl开发者_开发问答oadData.
If i can view via browser, why do i get http 404 file not found exception.
WebException was unhandled.
The remote server returned an error: (404) Not Found.
Thanks.
If the URL is valid perhaps they have some anti leaching mechanisms e.g. checking referer or cookie.
You can use something like Fidler to inspect web browser requests and ensure that your download requests are the same.
Make sure your request is same/similar to browser's one.
The easiest way is to use Fiddler and set it to log requests from all processes, than run the request from a browser and from you application. Look for differences between url, method and headers for 2 requests to see what is causeing it. (You many need to configure your program to use local proxy for web requests to get HTTP requests traced through Fiddler).
Try using this code. Set the Referer to something like google.com http://www.pastie.org/1429985
精彩评论