Configuring IIS for Silverlight Applications

Introduction 

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:

Const ADS_PROPERTY_UPDATE = 2 
'
if WScript.Arguments.Count < 2 then
 WScript.Echo "Usage: " + WScript.ScriptName + " extension mimetype"
 WScript.Quit
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 
MimeMapObj.SetInfo 
'
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 http://silverlight.net/.

    Related Content

    Comments

    I spent two or three days trying to diagnose a silver light problem on IIS7. In the end I found out there there was no .xap MIME type on my IIS7 (that came with Vista). When I added this my app worked fine.

    So this article is a little misleading.

    Regards

    Dave
    UK

    Mar 18 2008 by DaveUK

    Thanks Dave, I updated the article to reflect a more accurate description.

    Mar 19 2008 by bills

    Not able to see Silverlight 2.0 Application in IE 6 when page is refresh.

    Built in Silverlight 2.0, VB as code behind.

    Deployed in In Windows Server 2008 IIS 7.0
    Tested on
    - IE 7 (work fine)
    - IE 6 (not able to see SL after page refresh)
    - Mozilla 2.0 (work fine)

    Deployed in In Windows Server 2003 IIS 6.0
    Tested on
    - IE 7 (work fine)
    - IE 6 (work fine)
    - Mozilla 2.0 (work fine)

    Seem like IIS 7 is the root cause but I am not sure.

    Please help us.

    Jun 02 2008 by asthein

    VBScript ADDMIMETYPE.VBS doesnt seems to work fine for Windows 2003/IIS 6.0. It executes fine without any error but no MIME type is added on Master Site or other websites :

    cscript ADDMIMETYPE.VBS .xbap application/x-ms-xbap
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    MimeMap successfully added:
    Extension: .xbap
    Type: application/x-ms-xbap

    Anyone have a fix or workaround?
    Thanks,

    Rubal Jain

    Oct 16 2008 by RubalJ

    hi there,

    I have a chance to try Silverlight in both IIS6 and IIS7 with ASPHostCentral (http://www.asphostcentral.com) and it is just working absultely FINE :)

    This host provides me a control panel where I can add thee 3 MIME types directly:

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

    If you are working with IIS7 and you have a direct access to the server, you may notice that the configuration/interface will be slighly different. However, the main idea is still the same, i.e. to insert the 3 types of MIME mentioned above. If it is still not working, you may have to check as whether the Silverlight "framework" has been installed on your server or not :)

    If this troubles you, please just contact ASPHostCentral.com and I am 100% sure your problem will be resolved instantly. Well, I am just paying around $4.99/month to host my Silverlight site and certainly, I am glad to recommend their services to you all.

    I am now testing the latest Silverlight 3 and I will comment here further :)

    Jul 13 2009 by necro_mancer

    Hi there

    I am running vista home edition, with IIS 7, VDS 2008-SP1, RIA 3 -July 09 release, .NET 2, 3.5, however I am still getting this error, I have checked MIME types they are all configured in IIS.

    I am getting the following error message when running the default application:

    I> Error: Unhandled Error in Silverlight Application
    Code: 2104
    Category: InitializeError
    Message: Could not download the Silverlight application. Check web server settings
    /I>
    Please help

    Aug 05 2009 by zaffarn

    I am getting exactly the same error using IIS6 on Win 2003 Server.

    Any help would be much appreciated!

    Thx

    Helen

    Sep 18 2009 by helen w

    I had the same problem mime types where there everything was write but still no work. Then I looked at the web site property page, configuration build tab and found it was not in the build list so I ticked to include in build and it worked.

    Hope this helps
    Mark

    Sep 21 2009 by aMarke

    Mark, do you mean to add it to the Silverlight Applications? If so, I have already done that to no avail. If you mean something else, please explain, as I would really like to get this one over with.

    Thanks

    Helen

    Sep 22 2009 by helen w

    Very nice posts. If you looking for a reliable silverlight web hosting solution, you should arrive here to check more information

    http://www.webhost4lifereview.com/best-silverlight-web-hosting/

    Thanks

    Oct 13 2009 by aspfree.com

    FWIW, I finally solved this problem in my development environment.

    It appears that the MIME types (.xap, .xaml) need to be added to the individual web site, even if they have already been added to the root. Go figger. When I did this, I finally solved the problem.

    Cheers,
    Helen

    Oct 26 2009 by Helen W

    Submit a Comment

    You must Log In to comment.

    Microsoft Communities