Silverlight 2.0 App Not Starting - Fix IIS

Silverlight 2.0 introduces a new application model. Assets for Silverlight applications, i.e. code and resources are packaged up in a .xap file. When you install the latest version of the The Silverlight Tools for Visual Studio 2008 (http://www.microsoft.com/downloads/details.aspx?FamilyId=25144C27-6514-4AD4-8BCB-E2E051416E03&displaylang=en), you'll find that Silverlight projects automatically create the .xap packages when you check the Silverlight tab of the project properties:

image

These .xap files are nothing but zip archives with a different file extension (kinda like the Office 2007 documents are zip files ). You can take a look at the contents of a .xap by renaming it to .zip:

image

If you're serving up Silverlight applications packaged as .xap files from an IIS 7 server, i.e. from Windows Vista or from Windows Server 2008, you may also have to set up a MIME type for the .xap files.

Without the MIME type you'll find that your Silverlight apps seem to hang trying to download. The default download page would say something like "Silverlight is downloading your components....wait!!"

 image

but the download is actually not hanging. You can take a look what's really going on between the browser and the web server with the excellent fiddler tool.You'll see that the browser's request for the .xap file actually fails with a 404.3 error.

image

You can read the error in the fiddler tool or you can just get the nicely formatted error page by requesting the .xap file directly. The page even includes the necessary information to troubleshoot the problem.

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

 

  • Verify that the MIME map is enabled or add the MIME map for the Web site using the command-line tool appcmd.exe.
    1. To set a MIME type, use the following syntax: %SystemRoot%\windows\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='string',mimeType='string']
    2. The variable fileExtension string is the file name extension and the variable mimeType string is the file type description.
    3. For example, to add a MIME map for a file which has the extension ".xyz": appcmd set config /section:staticContent /+[fileExtension='.xyz',mimeType='text/plain']
    Warning: Ensure that this MIME mapping is needed for your Web server before adding it to the list. Configuration files such as .CONFIG or dynamic scripting pages such as .ASP or .ASPX, should not be downloaded directly and should always be processed through a handler. Other files such as database files or those used to store configuration, like .XML or .MDF, are sometimes used to store configuration information. Determine if clients can download these file types before enabling them.
  • If you're not comfortable with the command-line tool, you could also configure the MIME type with the IIS management tool (running with admin privileges, of course) by clicking on the MIME Types icon in the Features View

     

     image

    and then adding the type: application/x-silverlight-app for the File name extension .xap.

    image

     

    The good news for the people that are already running Vista SP1 or Windows Server 2008 is that both OSs already have IIS7 configured for the MIME type. If you upgrade to Vista SP1, then you need to have re-install IIS after you applied the service pack.

    Published Monday, March 3, 2008 9:14 AM by ChristophDotNet
    Filed under:

    Comments

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Monday, March 3, 2008 1:50 PM by Richard

    Presumably this applies to IIS6 as well?

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Monday, March 10, 2008 2:06 PM by sip

    Thanks a lot for this article! That's excatly what I was looking for. It fixed the issue!

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Saturday, March 15, 2008 10:07 PM by Christoph

    @Richard

    Unfortunately, I don't have an IIS67 box to test right now, but since .xap wasn't a MIME type when IIS 6 shipped you probably need add it to the configuration as well.

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Tuesday, April 15, 2008 9:55 AM by Alex

    I added the xap mime type to an IIS6 hosted silverlight 2 app and it fixed the hanging issue.  Cheers!

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Friday, September 26, 2008 6:39 PM by tophe

    Thanks for the tip.  Solved my problem!

    @Richard - I have IIS6 and it did the trick.

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Friday, October 31, 2008 1:23 PM by laguy88

    On Vista, adding the Mime Type for .svc only returned the .svc file and did not invoke the WCF handler

    Re-registering WCF on Vista did the trick.

    %Windir%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -r

    LA Guy

    # re: Silverlight 2.0 App Not Starting - Fix IIS

    Monday, February 2, 2009 8:47 AM by Maggy

    Found the solution to my problem. Firefox can see Silverlight as a popup. To enable: Tools>Options>Content>Popup exceptions> Silverlight.net>Allow>OK>OK>OK>reload tab

    To my surprise lots of Firefox users have the same problem, while lots of others, all with popup protection on, have no silverlight issue.

    Firefox warns in all other cases with a yellow top bar for popups, but doesn't show this yellow bar on blocked silverlight pages.

    For those Firefox users who've been drawn to this page by Google (like me) I hope you've not yet turned off Firefox addons nor reinstalled Firefox. These misconceptions go round on forums as real urban myths.

    Leave a Comment

    (required) 
    (required) 
    (optional)
    (required)