开发者

Silverlight 4 HttpWebRequest user agent string is null

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 whe开发者_JAVA技巧n 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!


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 ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜