HttpClient中的GetStringAsync方法在WP8中引发异常 [英] GetStringAsync method in HttpClient throw an exception in WP8

查看:109
本文介绍了HttpClient中的GetStringAsync方法在WP8中引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我为WP8开发了一个应用程序,开始时一切正常.但是,从昨天开始,我在尝试从URL检索 RSS数据时遇到错误.

Recently, I develop an App for WP8 and at the begining all worked OK. However, since yesterday nigth I was getting an error when trying to retrieve the RSS data from an url.

这是我用来获取数据的代码的一部分:

This is part of the code I use to get the data:

try
{
   HttpClient client = new HttpClient();
   var result = await client.GetStringAsync("http://www.scoop.it/t/recycling-by-miguel18/rss.xml");
   var parseResult = XDocument.Parse(result);
   . . .
}
catch (Exception ex)
{
   throw new Exception("Error: " + ex.Message);
}

其中source是包含用于获取 RSS数据的网址的字符串. 如前所述,一开始它工作正常,我能够使用它来处理数据.

Where source is the string which contain the url to get the RSS data. As commented, at the begining it was working OK, I was able to get the data in work with it.

现在,它引发以下错误: 响应状态代码不表示成功:404().

Now, it raise the following error: Response status code does not indicate success: 404 ().

如果我将网址直接放置到任何浏览器中,都可以看到 RSS供稿.因此,我不了解代码的问题.我有点迷茫.

If I put the url directly to any browser I can see the RSS feeds. So, I don't undertand what would be wrong with the code. I am a little lost.

如果您能帮助我找出问题所在,那将非常有帮助

If you can help me to figure out what is wrong that would be very helpful

致谢!

推荐答案

您需要为WP仿真器提供对Internet的访问.

You need provide access to internet for your WP emulator.

本文会有所帮助

将WP仿真器连接到互联网

这篇关于HttpClient中的GetStringAsync方法在WP8中引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆