Configuring IIS for Silverlight Applications


Purpose & Scope

Microsoft® SilverlightTM is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports fast, cost-effective delivery of high-quality video to all major browsers running on the Mac OS or Windows.

In most cases, hosters do not need to perform particular deployments to support Silverlight. However, check for the following basic items that could prevent Silverlight from functioning correctly.


MIME Types

In Windows Server 2008 IIS 7.0

All MIME types needed to support Silverlight are implemented by default in Windows Server 2008 IIS 7.0 and Windows Vista SP1.  Windows Vista RTM customers can add mime types by running ‘IIS Manager’, clicking on ‘Mime Types’, then clicking ‘add’ and adding the following mime types:

  • .xap     application/x-silverlight-app
  • .xaml    application/xaml+xml
  • .xbap    application/x-ms-xbap

Alternatively, you can add the following mime types to your %windir%\system32\inetsrv\config\applicationHost.config file in the <staticContent> section.

<mimeMap fileExtension=’.xaml’ mimeType=’application/xaml+xml’ />
<mimeMap fileExtension=’.xap’ mimeType=’application/x-silverlight-app’ />
<mimeMap fileExtension=’.xbap’ mimeType=’application/x-ms-xbap’ />

In Windows Server 2003 IIS 6.0

To enable IIS 6.0 in Windows Server 2003 or IIS7 in Windows Vista RTM with the appropriate MIME Types, add:

  • .xap     application/x-silverlight-app
  • .xaml    application/xaml+xml
  • .xbap    application/x-ms-xbap

Here is a VBS script you could run to enable each of these types:


if WScript.Arguments.Count < 2 then
WScript.Echo ‘Usage: ‘ + WScript.ScriptName + ‘ extension mimetype’
end if 

‘Get the mimemap object.  
Set MimeMapObj = GetObject(‘IIS://LocalHost/MimeMap’)  

‘Get the mappings from the MimeMap property.  
aMimeMap = MimeMapObj.GetEx(‘MimeMap’)  

‘ Add a new mapping.  
i = UBound(aMimeMap) + 1  
Redim Preserve aMimeMap(i)  
Set aMimeMap(i) = CreateObject(‘MimeMap’)  
aMimeMap(i).Extension = WScript.Arguments(0)  
aMimeMap(i).MimeType = WScript.Arguments(1)  
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, ‘MimeMap’, aMimeMap  

WScript.Echo ‘MimeMap successfully added: ‘
WScript.Echo ‘    Extension: ‘ + WScript.Arguments(0)
WScript.Echo ‘    Type:      ‘ + WScript.Arguments(1)

If you copy and paste the code above into a VBS file and save it as ADDMIMETYPE.VBS the syntax to add each type would be:

ADDMIMETYPE.VBS  .xap  application/x-silverlight-app ADDMIMETYPE.VBS  .xaml application/xaml+xmlADDMIMETYPE.VBS  .xbap application/x-ms-xbap

Using the IIS Manager User Interface in Windows Server 2003 IIS 6.0

1. Go to Start\Administrative Tools and run IIS Manager, see figure below:

2. Right click on the server name and select ‘Properties’, see figure below:

3. In the Properties Dialog, click on the ‘MIME Types’ button, see figure below:

4. In the ‘MIME Types’ Dialog, click the ‘New’ button, see figure below:

5. In the ‘MIME Type’ Dialog enter one MIME Type at the time:

  • .xap     application/x-silverlight-app
  • .xaml    application/xaml+xml
  • .xbap    application/x-ms-xbap

    see figure below:

    For detailed information on Silverlight, visit

  • Cannot Run Project in Expression Blend 3


    While working in Expression Blend 3 we found on one of our work computers we could not run the project from blend.

    We were on a Windows Vista and later Windows 7 box, and found that running the project would just return a message like: “Page cannot be displayed” or similar.

    Research showed that this was cause by the little application that hosts the local website that runs the project being blocked by an update to Window Defender and Forefront Security. This update mad a modification to the “hosts” file.


    The Fix

    Open this file: C:\Windows\System32\drivers\etc\hosts in Notepad, and add the following entry:       localhost

    Making it look something like this:


    A subsequent signature update to both Windows Defender and and Forefront Client Security, released on the same day as the earlier update, should not cause this problem. Gotta love that!

    Extract image bitmap from Media Element in DNN Modules with Silverlight 3.0

    For our upcoming new release of our DotNetNuke Module Silverlight Video Library with silverlight 3, a feature which previously took more than a few third party dll’s and full trust just to extract a jpg from a wmv was a nightmare.
    Now with silverlight 3 comes WriteableBitMap!
    You will quickly fall in love with WriteableBitMap as in just 3 lines of code you can effectively take a screenshot of any UI element and make that the contents for an Image.
    See below:

    public WriteableBitmap GetBitmapFromItem(FrameworkElement ctl)
    WriteableBitmap wb = new WriteableBitmap((int)ctl.ActualWidth, (int)ctl.ActualHeight);
    wb.Render(ctl, new TranslateTransform());
    return wb;

    Now just use that as the Source object for an image and presto. Since this works for all UI elements, suddenly image reflection becomes a step easier. You could even set a timer object to refresh this every few milliseconds so you get a reflection of video without the overhead of 2 x Media Elements.
    Download this DotNetNuke module from our website at: and stay tuned for our new release.