I work on a project target Windows Phone 7.5 and above.  

I use a method to get online image and check the type of the image, if it is gif then I will coonvert it into jpg and bind it to a image control, if jpg and png, just bind with no encoding.  

**But codes below throws a error very frequently, "The remote server returned an error: NotFound",why? I have already catch the WebException.**

```
public void GetOnlineImageAndReturnJPGStream(Action<Stream, string> callback, string uriString)
        {
            string errorstring = "";
            try
            {
                WebClient wc = new WebClient();
                wc.Headers[HttpRequestHeader.Referer] = "http://www.xici.net";
                wc.AllowReadStreamBuffering = true;
                wc.OpenReadCompleted += (s, e) =>
                {
                    if (e.Error == null && !e.Cancelled)
                    {
                        //check pic type
                        ImageTypeCheck.ImageType incomingIMGType = ImageTypeCheck.getImageType(e.Result);

                        switch (incomingIMGType)
                        {
                            case ImageTypeCheck.ImageType.Gif://if gif 
                                //deal with gif
                            case ImageTypeCheck.ImageType.Null:
                            case ImageTypeCheck.ImageType.Bmp:
                                //deal with bmp
                            case ImageTypeCheck.ImageType.Jpg:
                            case ImageTypeCheck.ImageType.Png:
                                //deal with jpg and png
                        }
                    }
                    else
                    {
                        errorstring = e.Error.Message;
                        callback(e.Result, errorstring);
                    }
                };

                wc.OpenReadAsync(new Uri(uriString, UriKind.Absolute));
            }
            catch (WebException webEx)
            {
                App.ShowToastNotification(webEx.Message);
            }
        }

```

**The unhandle exception is below:**

> 
> {System.Net.WebException: The remote server returned an error:
>  NotFound. ---> System.Net.WebException: The remote server returned an
>  error: NotFound. at
>  System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
>  asyncResult) at
>  System.Net.Browser.ClientHttpWebRequest.<>c\_*DisplayClasse.b*\_d(Object
>  sendState) at
>  System.Net.Browser.AsyncHelper.<>c\_*DisplayClass1.b*\_0(Object
>  sendState) --- End of inner exception stack trace --- at
>  System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
>  at System.Net.OpenReadCompletedEventArgs.get\_Result() at
>  xicihutong.DataServiceAgent.ServiceAgent.<>c\_*DisplayClassa.b*\_8(Object
>  s, OpenReadCompletedEventArgs e) at
>  System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
>  at System.Net.WebClient.OpenReadOperationCompleted(Object arg)}
>  [System.Net.WebException]: {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The
>  remote server returned an error: NotFound. at
>  System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
>  asyncResult) at
>  System.Net.Browser.ClientHttpWebRequest.<>c\_*DisplayClasse.b*\_d(Object
>  sendState) at
>  System.Net.Browser.AsyncHelper.<>c\_*DisplayClass1.b*\_0(Object
>  sendState) --- End of inner exception stack trace --- at
>  System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
>  at System.Net.OpenReadCompletedEventArgs.get\_Result() at
>  xicihutong.DataServiceAgent.ServiceAgent.<>c\_*DisplayClassa.b*\_8(Object
>  s, OpenReadCompletedEventArgs e) at
>  System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
>  at System.Net.WebClient.OpenReadOperationCompleted(Object arg)}
>  \_className: "System.Net.WebException"
>  \_data: null
>  \_dynamicMethods: null
>  \_exceptionMethod: null
>  \_exceptionMethodString: null
>  \_helpURL: null
>  \_HResult: -2146233079
>  *innerException: {System.Net.WebException: The remote server returned an error: NotFound. at
>  System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
>  asyncResult) at
>  System.Net.Browser.ClientHttpWebRequest.<>c*\_DisplayClasse.b\_*d(Object
>  sendState) at
>  System.Net.Browser.AsyncHelper.<>c*\_DisplayClass1.b\_\_0(Object
>  sendState)}
>  \_ipForWatsonBuckets: 0
>  \_message: "The remote server returned an error: NotFound."
>  \_remoteStackIndex: 0
>  \_remoteStackTraceString: null
>  \_source: null
>  \_stackTrace: {sbyte[96]}
>  \_stackTraceString: null
>  \_watsonBuckets: {byte[5616]}
>  \_xcode: -532462766
>  *xptrs: 0
>  Data: {System.Collections.ListDictionaryInternal}
>  HelpLink: null
>  HResult: -2146233079
>  InnerException: {System.Net.WebException: The remote server returned an error: NotFound. at
>  System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
>  asyncResult) at
>  System.Net.Browser.ClientHttpWebRequest.<>c*\_DisplayClasse.b\_*d(Object
>  sendState) at
>  System.Net.Browser.AsyncHelper.<>c*\_DisplayClass1.b\_\_0(Object
>  sendState)}
>  IPForWatsonBuckets: 0
>  Message: "The remote server returned an error: NotFound."
>  RemoteStackTrace: null
>  Source: "System"
>  StackTrace: " at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()\r\n
>  at System.Net.OpenReadCompletedEventArgs.get\_Result()\r\n at
>  xicihutong.DataServiceAgent.ServiceAgent.<>c\_*DisplayClassa.b*\_8(Object
>  s, OpenReadCompletedEventArgs e)\r\n at
>  System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs
>  e)\r\n at System.Net.WebClient.OpenReadOperationCompleted(Object
>  arg)"
>  WatsonBuckets: {byte[5616]}
> 
> 
> 

**Why? and how to handle it?**  

unfortunately the error message I post is a Unhandle Exception and told me that our server returns a error, but I thought that I've already catch the 404 error in the Unhandle exception, Why does it throw it anyway?