【发布时间】:2013-08-27 13:38:24
【问题描述】:
我是 windows phone 平台的新手。我试图发送一个 http 请求并打印响应。我创建了一个简单的 WP 7 项目尝试使用代码的 webClient
var client = new WebClient();
client.DownloadStringCompleted += (s, ev) => {System.Diagnostics.Debug.WriteLine( ev.Result); };
client.DownloadStringAsync(new Uri("http://www.google.com"));`
但它正在产生这个错误
{System.Net.WebException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 在 System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 在 System.Net.Browser.ClientHttpWebRequest.c_DisplayClasse.b_d(Object sendState) 在 System.Net.Browser.AsyncHelper.c_DisplayClass1.b_0(对象 sendState) --- 内部异常堆栈跟踪结束 --- 在 System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 在 System.Net.DownloadStringCompletedEventArgs.get_Result() 在 PanoramaApp2.MainPage.<.ctor>b__0(Object s, DownloadStringCompletedEventArgs ev) 在 System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) 在 System.Net.WebClient.DownloadStringOperationCompleted(Object arg)}
我也尝试过HttpWebRequest。但也会产生异常。我花了很多时间来解决这个问题,但仍然无法从http请求中得到响应。请帮助我。
【问题讨论】:
-
我也试过了,但是代码没有问题。我得到了结果,错误为空。
标签: windows-phone-7 windows-phone