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:
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:
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!!"
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.
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.
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.
- To set a MIME type, use the following syntax: %SystemRoot%\windows\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='string',mimeType='string']
- The variable fileExtension string is the file name extension and the variable mimeType string is the file type description.
- 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']
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
and then adding the type: application/x-silverlight-app for the File name extension .xap.
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.