I have been part of Telerik’s Silverlight team for almost a year now, and I too well know that our marketing team is just two floors away to say anything bad about marketing. So I will just say that now having Silverlight 2 in its official version out, marketing mix should adopt one more P in its four P’s concept, Ptechnology. That is why, I will try to explain this topic step by step, so that all marketing guys attracted by the name of this topic can delete the first paragraph and give it to their development teams for consideration.
Since its official release, Silverlight 2 exposes a lot of hot trends and technology techniques as the UI Automation and Accessibility that we were so passionate about lately. Another nice thing about Silverlight is that the server technology and client html technology at runtime are fairly similar to Flash. This topic shows how reasonably easy it is to use cross-domain Silverlight application (xap files) as banner ads hosted on one domain and published onto another. There are certain steps that should be followed in order to integrate existing Silverlight xap file into another website.
1. Enable Silverlight in the Publisher’s website
2. Configure the object tag to access cross-domain Silverlight applications
3. Create access policy to enable cross-domain access
Now, I will have to use two different computers to show you how the cross-domain banner works. I have hosted a simple Silverlight application that consists of Telerik's RadWindow for Silverlight and a simple image banner inside it. The application is called "BannerHost" and is hosted on my IIS server which is currently exposed to the "Publisher" website (http://borisov.telerik.com/BannerHost/ClientBin/BannerAd.xap). The publisher website will access this banner and show it as part of its web content. Later I will talk about the way access policies are set to enable accessibility to services and resources by Silverlight.
A prerequisite for those who don’t use IIS 7.0 is to configure their web server to associate .xap files to the MIME Type “application/x-silverlight-app”. To enable Silverlight on our publisher webpage using Visual Studio 2008 you should right click on the webpage and select properties. Then you should add existing Silverlight application in order to enable Silverlight on your existing ASP.NET website. After we have enabled Silverlight on our existing web page we configure our html object tag that hosts the Silverlight application to access a resource on a different domain instead of the local Silverlight application you have just referenced.
The Silverlight object tag looks like this:
You can also configure the Silverlight application in your aspx webpage by editting the following code.
Now, our "Publisher" website, hosted on http://paskov.telerik.com/ has silverlight enabled and its source is set to our cross-domain resource. PublisherTestPage.aspx is currently blank and consists only of the Silverlight application hosted on http://borisov.telerik.com/.
In order to access all resources in one domain from another you should configure some access policies on the domain in which the Silverlight application is hosted. One way is to create ClientAccessPolicy.xml file and place in the root of the domain for example http://borisov.telerik.com/ClientAccessPolicy.xml. In our case we used the following preconfigured xml file that gave us full access to the resources.
For security reasons it’s advisable to check the online resources about “Making a service online across domain boundaries” at http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx Moreover, you can check an official guide by Microsoft on the same issue called "Silverlight Advertising Serving Publishing Guide".
Vladimir Enchev is Director of Engineering, Native Mobile UI & Frameworks