使用 WebClient() 从 Silverlight 访问 RSS 源时出错
我从 John Papa 的书中下载了代码: http://silverlight-data.com/
和我正在成功运行第 7 章示例,该示例允许您按
一个按钮,它会从 digg.com 读取 RSS,然后显示它。
因此,然后我替换了 digg URL
与我的 RSS 提要:
但我在DownloadStringCompleted 事件:
结果“e.Result”引发了“System.Reflection.TargetInitationException”类型的异常 错误= {System.Security.SecurityException ---> System.Security.SecurityException:安全错误 bei System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) bei System.Net.BrowserHttpWebRequest。<>c__DisplayClass5。
我尝试了其他 RSS 提要,例如: http://news.google.com/nwshp?hl= en&tab=wn&output=rss
我得到了相同的安全错误。
我该怎么做才能避免出现这些错误,以便我可以从 Silverlight 使用这些源?
I'm downloaded the code from John Papa's book here: http://silverlight-data.com/
and am sucessfully running the Chapter 7 example which allows you to press
a button and it reads RSS from digg.com and then displays it.
So, then I replaced the digg URL
with my RSS feed:
but I get this error on the DownloadStringCompleted event:
Result 'e.Result' threw an exception of type 'System.Reflection.TargetInvocationException'
Error = {System.Security.SecurityException ---> System.Security.SecurityException: Security Error
bei System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
bei System.Net.BrowserHttpWebRequest.<>c__DisplayClass5.
I tried other RSS feeds, e.g.:
http://news.google.com/nwshp?hl=en&tab=wn&output=rss
and I get the same security error.
What can I do to avoid getting these errors so that I can consume these feeds from Silverlight?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试访问与运行 silverlight 应用程序的 url 不同的网站/url,则需要设置跨站点策略文件或访问允许访问的站点。
[编辑添加了 Tim Heuer 的链接]
If you try to access a website/url that differs from the url your silverlight application is run under you will need to set up a cross site policy file or access a site that has one allowing access.
[edit added Tim Heuer's links]
另请参阅 http://silverlight.net/learn/learnvideo.aspx?video=65672 和 http://silverlight.net/learn/learnvideo.aspx?video =47174
Also please see http://silverlight.net/learn/learnvideo.aspx?video=65672 and http://silverlight.net/learn/learnvideo.aspx?video=47174