Jun 252008

In getting back up to speed with Silverlight, and in particular the new Silverlight 2 beta 2, I’ve been surfing through the many quickstart topics on various web sites. While skimming “Receiving Plain XML Messages with Silverlight” these words lept out at me:

note: The WebClient class does not currently support cross-domain calls.

Say what?

The article then proceeds to show how to make an XML call using Silverlight’s WebClient class, and oh by the way it’s a cross domain call.

Nice job, guys.

Here’s what that article probably meant to say, but managed to get lost in the words:

Silverlight’s WebClient class supports cross-domain HTTP requests *IF* the target server allows cross-domain requests. 

It really is that simple. 

To configure a server to support cross-domain requests, read “How to: Make a Service Available Across Domain Boundaries“. 

  2 Responses to “Silverlight Supports Cross-Domain Calls”

  1. I have been trying to use cross domain calls for a while now because I’m trying to use silverlight to retreive/update google spreadsheet data. The website will be hosted on something free like google pages.

    I get a security error when it tries to do the HTTPwebrequest, no matter what I do. JS, VB or C#.

    So that probably means google’s spreadsheet site is disabling cross domain communication, right? Do you have an example site url I can test with to prove this to myself?

    Even better, is there anything out there that can host a sort of shared updateable web database, for free? I want to create a turn based game with silverlight that connects all the people using it to one free online source of info. When a player takes a turn, it updates the online source.

    I THINK the microsoft Application Based Storage: ATOM + IFM api/sdk may help, but I have a feeling it will only store info per liveID, and not shareable to multiple people. Also I don’t know if it works with silverlight.

    Here’s the google group discussion I started, if you want to see more info.


  2. Hi Neo42,

    Silverlight’s cross-domain communication option requires that the server you’re trying to contact cross-domain host a file (crossdomain.xml) that specifies which domains that server will accept cross-domain requests from, and that the domain that your Silverlight app is on is in that server’s allowed list.

    So, that means that the google server that provides access to the spreadsheet file needs to provide such a crossdomain.xml file, and it needs to include your google pages domain that hosts your Silverlight app. I don’t know if google will do that for you or not.

    ATOM pub/sub will allow you to update a common shared document that is viewable by many. Many blog engines support this API standard. Also, there’s the much older WEBDAV API which also supports updating web content.

    One thing you didn’t mention was access control. If everybody can update the central state file, what’s to prevent everyone from modifying that file by hand and cheating? Or from looking at the state file to see the secret state information of the other players?

    If the state modification you want to do on each turn is to append information to the end of the state file, you can do that with plain old NNTP. Create a newsgroup on an NNTP server, then use NNTP to read the latest messages and post new messages to the end of the queue. Chess by email has been played like this for ages.

    Good luck!

Sorry, the comment form is closed at this time.