How to host Silverlight in SharePoint

Hosting Silverlight in SharePoint is actually pretty simple in its basic form. If you want more control over your Silverlight app within SharePoint there's always the excellent Silverlight Blueprints. The only prerequisite i'm aware of is that the IIS server SharePoint is running on has a mime type that support Silverlight (extension: .XAP, MIME-type: application/x-silverlight).

The simple way I've been doing it, is as follows:

  1. Upload the Silverlight XAP to your SharePoint site's 'Shared Documents' document library.

  2. Create a new Web Part page in SharePoint (ensure the Document Library is set to 'Shared Documents')

  3. Then Edit the page and add a Content Editor WebPart

  4. Open the Source Editor and paste the HTML source from your Silverlight test page

  5. Adjust the Width and Height so you can see the page and your Silverlight app

 

And you're done! - Your Silverlight app is hosted in SharePoint. My next blog post will show how you can use SharePoint's web services to perform actions on WSS from within your Silverlight App. Quite an appealing prospect given that the world and his dog are now using SharePoint but still with the standard vanilla UI. Imagine the possibilities of sexing up WSS' collaboration features with Silverlight.