Wednesday, August 15, 2012

Allowing cross domain calls in Silverlight

Allowing cross domain calls in Silverlight

As stated in this article by Microsoft you need to host a xml config file on the webservice from which you application was downloaded to allow the application to make cross domain calls.

Are there any workaround for this? My silverlight application can be run OOB or possibly hosted on some random webserver (where a crossdomain.xml or clientaccesspolicy.xml cannot be placed).

The calls i need to make from the silverlight application are calls to various json webservices (using the SilverlightServiceClient from ServiceStack), but i do not know the URL in advance.

Cheers!

Answers & Comments...

Answer: 1

It sounds like you are not actually in a Cross Domain scenario, but not sure where your JSON services are located. The article you refer to relates to where you want to call services on a server other than the one hosting the Silverlight app.

If the JSON services are on other machines, out of your control, then you should be calling them from your webserver and not your client. Then there is no Cross Domain issue. You just wrap the calls in your own API on your own web server (which also gives you an extra level of separation in case a third-party service goes away).

The only thing I am not sure about is if OOB mode remembers what server it came from (but I think it does).

Answer by HiTech Magic for Allowing cross domain calls in Silverlight

Answer: 2

See this question on how you can use Global (or per-service) HTTP headers to enable CORS with ServiceStack:

servicestack REST API and CORS

Answer by mythz for Allowing cross domain calls in Silverlight




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog