远程服务器返回错误:未找到
问题描述:
我写了一个程序,它发送特定站点的请求并获取响应。它适当地与本地主机一起运行。但是,如果我把www.google.com然后提示错误为 “遥远而明亮服务器返回错误:未找到”远程服务器返回错误:未找到
****代码* ** * *
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);
}
}
}
请告诉我soultion thanx提前
答
您的代码适用于我。
您可以通过设备/模拟器的IE访问Google吗?
我怀疑这是您本地的网络问题,与设备无关。
它在模拟器中的IE中工作吗?尝试通过NetworkInterface.GetIsNetworkAvailable()检查连接是否可用 – Robert 2011-03-14 10:50:20