问题描述:

Currently with Windows Phone 7 if I access a page that returns a StatusCode of 500 or something besides 200 OK I get a message saying the NotFound. In silverlight there are a couple options for handling this:

  1. Use SilverlightFaultBehavior if you control the REST Service (I don't though)
  2. Use HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);

I'm wondering if there are any options like this for the Windows Phone 7.

网友答案:

All you have to do is catch the WebException, and access the response within that. Then you can get at the status code, response stream etc.

If that's no use to you, please post the code you're using and what you're trying to do - it's hard to know exactly what you've tried at the moment.

网友答案:

HttpWebResponse includes a StatusCode property. Can't you use that?

webResponse = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult);

webResponse.StatusCode;
相关阅读:
Top