0

下面的代码编译,但它不显示网站的文本或照片。我只想运行一个涉及与 Silverlight 进行 HTTP 通信的程序。知道为什么我没有让网站显示吗?我只是在 textBlock 中得到“发生错误”来显示

namespace SilverlightApplication4
{
    public partial class MainPage : UserControl
    {
        string baseUri = "http://yahoo.com";
        WebClient client = new WebClient();            

        public MainPage()
        {
            InitializeComponent();
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);        
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            client.DownloadStringAsync(new Uri(baseUri));
        }

        void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
                textBox.Text = "Using WebClient: "+  e.Result;
            else
            {
                textBox.Text = e.Error.Message;
                textBlock.Text = "error occurred";
            }
        }
    }
}
4

1 回答 1

1

It is a crossdomain issue where the xml is not present in the server as a result you are getting the exception

Heres a link where I found the issue you can go through it

Security Exception

于 2013-09-16T09:38:22.057 回答