Web client failed with remote NotFound server

I am creating a wp7 application. I use WebClient to capture data from the server. It used to work, although suddenly it didn’t work.

  static void downloadData(string uri, Action<object, DownloadStringCompletedEventArgs> onComplete) { Debug.WriteLine("Downloading: " + uri); WebClient data = new WebClient(); data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(onComplete); data.DownloadStringAsync(new Uri(uri)); } static void data_SectionDownloadCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { // throws NotFound throw e.Error; } // ... } 

When I go to the URI in question in my browser, it works fine.

An exception:

 "The remote server returned an error: NotFound." {System.Net.WebException} 

What am I doing wrong here?

Update . I restarted the emulator and now it works fine. Weird Maybe this is a problem in the emulator? I hope I can not play it on the device itself.

+4
source share
3 answers

NotFound is a common error, which basically means "Error". Behind it there is a real exception that must be found in order to find. The easiest way I've found is Intellitrace , which allows you to view all the exceptions that have ever occurred on your web server. If you look right in front of your NotFound, you will find a real exception that supports it.

If Intellitrace is not an option, add more / better logging on your server and client. Google has a lot of tips, a good example of deeper debugging:

http://www.mostlydevelopers.com/blog/post/2009/01/14/debugging-tips-ndash3b-the-remote-server-returned-an-error-notfound.aspx

+1
source

I had a similar experience with the emulator. I often open Internet Explorer and browse the site before testing any application that uses the network. In addition, it is better not to change the IP address of the machine running the emulator, DHCP or manually. Finally, I suggest that you handle any error scenarios with the error message displayed in the MessageBox.

Hh, indyfromoz

0
source

I also get this accident. Even on real devices. Repeat usually corrects it.

Unfortunately, this is one of the problems that you need to know and write code that will serve when working in a randomly connected environment.

0
source

All Articles