WP8:下载任何RSS源时WebClient API DownloadStringAsync抛出System.Net.WebException

时间:2014-02-16 17:10:21

标签: windows-phone-8 webclient

我正在尝试使用WebClient api在我的WP8应用程序中下载RSS源,并且正在获取System.Net.WebException:NotFound,我尝试了各种不同的RSS源,结果是一样的,我错过了什么,这是示例代码

public class RssFeedDownloader
{
    public Task<string> GetRssFeed(string feedUrl)
    {
        var tcs = new TaskCompletionSource<string>();

        var client = new WebClient();
        client.DownloadStringCompleted += (s, e) =>
        {
            if (e.Error == null)
            {
                tcs.SetResult(e.Result);
            }
            else
            {
                tcs.SetException(e.Error);
            }
        };

        client.DownloadStringAsync(new Uri(feedUrl));

        return tcs.Task;
    }
}

0 个答案:

没有答案