Windows Phone では、if で取得WebExceptionできStatusCode == HttpStatusCode.NotFoundます
- サーバーが 404 を返しました
- 接続が悪いため、サーバーが見つかりません。
On Windows PhoneWebExceptionのステータスはWebExceptionStatus.UnknownError両方の場合です。
1case とcaseを区別するにはどうすればよい2ですか?
私が観察したのは、接続が悪い (サーバーが見つからない)ResponseUriが null で、WebResponseヘッダーに0アイテムが含まれている場合です。
EDIT
ResponseUriは null ではなく、OriginalString空です
これを行うのは安全ですか:
catch (WebException ex)
{
switch (ex.Response.StatusCode)
{
...
case HttpStatusCode.NotFound:
if (ex.Response.ResponseUri == null
|| string.IsNullOrEmpty(httpWebResponse.ResponseUri.OriginalString))
DoServerNotFound();
else
DoServerReturned404();