Windows phone 7 远程服务器返回错误:未找到
我写了一个程序,它发送特定站点的请求并得到响应。它可以与localhost一起正常运行。但是,如果我把www.google.com放进去,它会提示错误为“远程服务器返回了一个错误:找不到” ***代码******Windows phone 7 远程服务器返回错误:未找到,windows-phone-7,Windows Phone 7,我写了一个程序,它发送特定站点的请求并得到响应。它可以与localhost一起正常运行。但是,如果我把www.google.com放进去,它会提示错误为“远程服务器返回了一个错误:找不到” ***代码****** using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;
namespace WindowsPhoneApplication2
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
var request = (HttpWebRequest)WebRequest.Create(new Uri(@"http://www.google.com"));
request.BeginGetResponse(r =>
{
var httpRequest = (HttpWebRequest)r.AsyncState;
var httpResponse = (HttpWebResponse)httpRequest.EndGetResponse(r);
using (var reader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = reader.ReadToEnd();
Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { textBox1.Text = response; }));
}
}, request);
}
}
}
请告诉我答案
thanx提前您的代码适合我 你能在设备/模拟器上从IE访问Google吗?
我怀疑这是您本地的网络问题,与设备无关。它在IE emulator中工作吗?尝试通过NetworkInterface.GetIsNetworkAvailable()检查连接是否可用