首页 文章

无法使用silverlight从sharepoint下载xml .

提问于
浏览
0

EDIT: 切换到Silverlight 4,这让我更进一步 .

我有一个xml,可以在sharepoint库中存储高分 . sharepoint站点是https,我可以点击xml的“复制快捷方式”,它出现在浏览器中,所以我知道我可以访问它 .

我试图使用Silverlight中的webclient来拉这个xml,如下所示 .

Uri url = new Uri("https://server/HighScores.xml", UriKind.Absolute);

WebRequest.RegisterPrefix("https://",System.Net.Browser.WebRequestCreator.ClientHttp); 
var client = new WebClient(); 
client.Credentials = new NetworkCredential("username", "password", "domain"); 
client.UseDefaultCredentials = false; 
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); 
client.DownloadStringAsync(url);

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    if (e.Error == null)
    {
         string xmlData = e.Result;
         HtmlPage.Window.Alert(xmlData);
    }
}

使用此代码,我的Silverlight游戏弹出,但窗口中的Windows凭据登录immediatley . 当我在这里输入正确的crdentials时,正如我在后面的代码中所做的那样,我得到了followig错误 .

e.Error {System.Security.SecurityException ---> System.Security.SecurityException:安全错误 . 位于System.Net.Browser.ClientHttpWebRequest的System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) . <> c_DisplayClass5.b_4(Object sendState),位于System.Net.Browser.AsyncHelper . <> c_DisplayClass2.b_0(Object sendState) ---内部异常堆栈跟踪的结束---在System.Net.WebClient的System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)的System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state)中 . System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)中的GetWebResponse(WebRequest请求,IAsyncResult结果)} System.Exception

有帮助吗?

1 回答

相关问题