我正在构建一个wp7应用程序。我使用WebClient
从服务器获取数据。过去,它一直在工作,尽管突然间它失败了。WebClient失败,远程服务器“NotFound”
static void downloadData(string uri, Action<object, DownloadStringCompletedEventArgs> onComplete)
{
Debug.WriteLine("Downloading: " + uri);
WebClient data = new WebClient();
data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(onComplete);
data.DownloadStringAsync(new Uri(uri));
}
static void data_SectionDownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
// throws NotFound
throw e.Error;
}
// ...
}
当我在浏览器中访问有问题的URI时,它工作正常。
例外:
"The remote server returned an error: NotFound." {System.Net.WebException}
我在做什么错在这里?
更新:我重新启动了模拟器,现在它工作正常。奇怪的。也许这是模拟器中的问题?希望我不能在实际的设备上重现它。
我开始与我的Azure存储模拟器一个blob文件中获取此。我确定我将容器设置为“公开”,但我一直收到WebClient NotFound错误。我可以通过Internet Explorer访问azure blob。 – markti 2012-09-07 01:36:04