Silverlight 2.0: Cross-Domain Access Redux

Scott Guthrie has been publishing some "pre release" very cool blog posts about the upcoming Silverlight 2.0 release. One of the most interesting features is that cross-domain access will be allowed (think JSONp and Crockford's JSONRequest or other cool ideas). Here's a short quote:

Cross Domain Network Access

Silverlight 2 applications can always call back to their "origin" server when making network calls (meaning they can call URLs on the same domain that the application was downloaded from). Silverlight 2 applications can also optionally make cross-domain network calls (meaning they can call URLs on different domains from where the application was downloaded from) when the remote web server has an XML policy file in place that indicates that clients are allowed to make these cross-domain calls.

Silverlight 2 defines an XML policy file format that allows server administrators to precisely control what access a client should have. Silverlight 2 also honors the default Flash cross domain policy file format - which means that you can use Silverlight 2 to call any existing remote REST, SOAP/WS*, RSS, JSON or XML end-point on the web that already enables cross-domain access for Flash clients.

Digg.com has a pretty cool set of Digg APIs that they publish over HTTP. Because they have a Flash cross-domain policy file in place on their server, we can call them directly from our Silverlight Digg client application (and not require us to tunnel back through our web-server to reach their APIs).

In order to implement the Flash Cross Domain policy you need a file on your server named crossdomain.xml . Here is an example:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<allow-access-from domain="*" />

You can see the little asterisk up there that works in a manner similar to the "allow user" element in your web.config for authorization.

While this does require sites wishing to serve Flash / Silverlight content via an API to add a file to their site, it's still a big step in the right direction.

I haven't done much anything yet with Silverlight because I've been waiting for what is now "2.0" with .NET Framework support and other features. But the time is coming soon! I predict Silverlight will become a major player in this space. It may not ever outstrip Flash - which by now is ubiquitous, but you will know about it. Major sites will start using the technology.

Jesse Ezell, who probably has some of the best .NET AND Flash credentials around, sums it up:

"...about the only thing Flash has going for it from my perspective is adoption. Adoption isn't hard to achieve, especially for the people that ship the operating system 90% of the world uses. As such, it's just a matter of time till that is no longer part of the equation. Adobe has a lot of work to do in the mean time, and the clock is ticking. Open sourcing Flex is a really good start in the right direction... unfortunately, Flex was built on top of the wrong platform from the start (something I told the Flex team while Flex was still in Alpha), so this last effort, while a good one, still might not be big enough to turn the tide that is coming. Now, this isn't to say that Flash isn't a great format and doesn't enable a lot of scenarios (like I said, my job is working with Flash and I'd be doing something completely different if it wasn't for Flash). So, Flash is great. Silverlight just solves a lot of the major problems that I've run into with Flash."

The bottom line for me is that with Silverlight 2.0, developers will be able to choose between writing powerful, rich desktop applications or powerful, rich browser applications, and we will no longer have the big skillset difference between the two. This is what the vision of the .NET framework was originally. Microsoft is continuing to expand on and deliver on that vision.

On Twitter, On Dasher!

Live Messenger is helpful. It's relatively unobtrusive, and if somebody IM's you and you are busy people understand the delays. In fact, it was down for a good part of today and I really did miss the convenience (WebMessenger was down too). But Twitter! Twitter is downright harmful to you as a developer. I mean, I go on there and look at some of the people I'm following and there's just this puke-pot stream of garbage with people jabbering like teenage girls on the phone. Much content, little substance. No, thanks!

Visual LINQ

I was just corresponding with MVP Jon Skeet and he pointed me to his latest creation, Visual LINQ. Basically, Jon has the beginnings of a WPF visual LINQ Query Analyzer that animates the actual process of how a LINQ query expression is evaluated right in front of your eyes. I believe this may have some strong teaching / learning tools potential. Go, Sir Jon! Skeet's new book, "C# In Depth" from Manning, will be out soon and we hope to have a feature article combined with a book giveaway for our top posters contest in March.