If you’ve tried placing a Silverlight application in a HTML page in Expression Web 2 (or any other web authoring application for that matter) and previewing it in your browser you know it doesn’t work. Here is a small exerpt from my upcoming book Sams Teach Yourself Microsoft Expression Web 2 in 24 Hours that explains how you can use the Expression Development Server to trick your browser into previewing Silverlight applications without having to run them off a server:
To make sure everything is working properly, you should preview the page in your browser. But if you do all you’ll see is an empty white page. This is because Silverlight is a server-side script that must be running on a web server to work properly. In other words technically you need to upload your files to a web server and test them from there. Fortunately there is a way around this problem: Because a big part of Expression Web 2 is the ability to create advanced dynamic websites using Microsoft’s server-side script language ASP.NET, the program comes equipped with a small application called Expression Development Server. This application creates a virtual server on your computer that behaves like a web server and lets you run server-side scripts in pages even though they are only stored on your computer. You will be introduced to the Expression Development Server in more detail in Hours 22, “Beyond the Basics: PHP in Expression Web 2,” and 23, “Beyond the Basics Part 2: Building a Site with ASP.NET.”
The problem at hand is that the Silverlight script will run only on a web server. So to be able to preview the application you need to make Expression Web 2 think that the page you are currently working with is actually an ASP.NET page. That way it will be previewed using Expression Development Server and the Silverlight script will run properly. Doing so is surprisingly simple: Open the HTML file that contains the Silverlight application you want to preview, select File, Save As on the menu bar, and change the file extension to .aspx – the extension for ASP.NET pages that can contain regular HTML code. Now when you open the page it will be previewed in the browser through Expression Development Server and the Silverlight application will run properly.
Clever eh? Now go crack open your piggybank and buy my book!
3 replies on “Previewing Silverlight Applications in Your Browser With Expression Development Server”
Hmmm, what version of Silverlight are you working with?
One other thing you can do is set the Preview tab of the Site Settings dialog box to use the Expression Development Server to preview all web pages. But you should clarify that not all Silverlight applications require previewing with that server. If you’re using Silverlight 2.0 asp.net controls, the controls need to be on an aspx page anyway, so shouldn’t be on an HTML page in the first place. What kind of Silverlight application are you referencing that requires the Expression Development Server? Hmmmm….
I came across this problem when I tried to preview the excellent Slide.Show application from Vertigo. It’s quite possible that it’s refusal to work without the Expression Dev. Server is that it’s based on Silverlight 1 but even so chances are people are going to run into the problem at some point – if for nothing else when they are using Slide.Show.