Silverlight 4 HttpWebRequest user agent string is null

Deadly 提交于 2019-12-25 00:42:52

问题


The problem

I have a page with a silverlight object. It attempts to retrieve XML from another (external cross domain) page. But I am struggling with a security exception.

I have this code working brilliantly in WPF.

When using a website hosting a silverlight application with the same code, the user agent string of the HttpRequest object is null (and seemingly cannot be set). In fact there is no header information at all - this causes a security exception when attempting to make my asynchronous call.

The question

Why is the user-agent string (and header information) null in my silverlight 4 application when making an asynchronous call using HttpWebRequest?

Thanks in advance!


回答1:


sounds like you are might be hitting a cross domian issue does your external xml have a clientaccesspolicy file or a crossdomain file on the site? http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx

Also what is the exception ? can you post.

Update:

OK, Have looked and run your code and yes it a crossdomian issue. The site "http://eu.wowarmory.com/" has a crossdomian file but only allow access from the sites listed in that file ? is you site one of those ? If not you are hitting crossdomain security. (WPF runs on the full CLR and so does not have these restrictions.)

There are options ... -Silverlight 4 running in elevated trust is one - but that is OOB

-Doing it in Javascript and the passing the data into Silverlight

-Get you server to do the work for you i.e. proxy

-Get them to change the crossdomain file !

There are others it really depends on what you are trying to achieve overall? can you explain more ?



来源:https://stackoverflow.com/questions/2908072/silverlight-4-httpwebrequest-user-agent-string-is-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!