Silverlight:如何在Visual Studio上解决HttpsCompleted安全异常,而不仅仅在IIS 7上

时间:2011-03-24 18:15:27

标签: silverlight windows-phone-7

我尝试使用Silverlight中的HttpsCompleted来调用http://twitter.com/statuses/public_timeline.xml(如How do I load an xml file in XDocument in Silverlight?所示),但它永远不会被调用。

using System;
using System.Net;
using System.Xml.Linq;

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;

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
        WebClient wc = new WebClient();
        wc.DownloadStringCompleted += HttpsCompleted;
        wc.DownloadStringAsync(new Uri("http://twitter.com/statuses/public_timeline.xml"));
    }

    private void HttpsCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
            textBlock1.Text = xdoc.FirstNode.ToString();
        }
    }
}

0 个答案:

没有答案