How to: Configure IIS 5.0 and IIS 6.0 to Deploy WPF Applications

 

You can deploy a Windows Presentation Foundation (WPF) application from most Web servers, as long as they are configured with the appropriate Multipurpose Internet Mail Extensions (MIME) types. By default, Entity with relative path '../Token/TLA%23tla_iis70_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. is configured with these MIME types, but Microsoft Internet Information Services (IIS) 5.0 and Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. are not.

This topic describes how to configure Microsoft Internet Information Services (IIS) 5.0 and Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. to deploy WPF applications.

Entity with relative path '../Token/autoOutline_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'.

System_CAPS_ICON_note.jpg Note

You can check the UserAgent string in the registry to determine whether a system has .NET Framework installed. For details and a script that examines the UserAgent string to determine whether .NET Framework is installed on a system, see Detect Whether the .NET Framework 3.0 Is Installed.

You should adjust the content expiration setting to 1 minute. The following procedure outlines how to do this with IIS.

  1. Click the Start menu, point to Administrative Tools, and click Internet Information Services (IIS) Manager. You can also launch this application from the command line with "%SystemRoot%\system32\inetsrv\iis.msc".

  2. Expand the IIS tree until you find the Default Web site node.

  3. Right-click Default Web site and select Properties from the context menu.

  4. Select the HTTP Headers tab and click "Enable Content Expiration".

  5. Set the content to expire after 1 minute.

You must register several MIME types and file extensions so that the browser on the client's system can load the correct handler. You need to add the following types:

ExtensionMIME Type
.manifestapplication/manifest
.xamlapplication/xaml+xml
.applicationapplication/x-ms-application
.xbapapplication/x-ms-xbap
.deployapplication/octet-stream
.xpsapplication/vnd.ms-xpsdocument
System_CAPS_ICON_note.jpg Note

You do not need to register MIME types or file extensions on client systems. They are registered automatically when you install Microsoft .NET Framework.

The following Entity with relative path '../Token/TLA%23tla_visualbscrpt_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. sample automatically adds the necessary MIME types to IIS. To use the script, copy the code to a .vbs file on your server. Then, run the script by running the file from the command line or double-clicking the file in Microsoft Windows Explorer.

  
      ' This script adds the necessary Windows Presentation Foundation MIME types   
' to an IIS Server.  
' To use this script, just double-click or execute it from a command line.  
' Running this script multiple times results in multiple entries in the IIS MimeMap.  
  
Dim MimeMapObj, MimeMapArray, MimeTypesToAddArray, WshShell, oExec  
Const ADS_PROPERTY_UPDATE = 2   
  
' Set the MIME types to be added  
MimeTypesToAddArray = Array(".manifest", "application/manifest", ".xaml", _  
    "application/xaml+xml", ".application", "application/x-ms-application", _  
    ".deploy", "application/octet-stream", ".xbap", "application/x-ms-xbap", _  
    ".xps", "application/vnd.ms-xpsdocument")   
  
' Get the mimemap object   
Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap")  
  
' Call AddMimeType for every pair of extension/MIME type  
For counter = 0 to UBound(MimeTypesToAddArray) Step 2  
    AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1)  
Next  
  
' Create a Shell object  
Set WshShell = CreateObject("WScript.Shell")  
  
' Stop and Start the IIS Service  
Set oExec = WshShell.Exec("net stop w3svc")  
Do While oExec.Status = 0  
    WScript.Sleep 100  
Loop  
  
Set oExec = WshShell.Exec("net start w3svc")  
Do While oExec.Status = 0  
    WScript.Sleep 100  
Loop  
  
Set oExec = Nothing  
  
' Report status to user  
WScript.Echo "Windows Presentation Foundation MIME types have been registered."  
  
' AddMimeType Sub  
Sub AddMimeType (Ext, MType)  
  
    ' Get the mappings from the MimeMap property.   
    MimeMapArray = MimeMapObj.GetEx("MimeMap")   
  
    ' Add a new mapping.   
    i = UBound(MimeMapArray) + 1   
    Redim Preserve MimeMapArray(i)   
    Set MimeMapArray(i) = CreateObject("MimeMap")   
    MimeMapArray(i).Extension = Ext   
    MimeMapArray(i).MimeType = MType   
    MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray  
    MimeMapObj.SetInfo  
  
End Sub  

System_CAPS_ICON_note.jpg Note

Running this script multiple times creates multiple MIME map entries in the Microsoft Internet Information Services (IIS) 5.0 or Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. metabase.

After you have run this script, you may not see additional MIME types from the Microsoft Internet Information Services (IIS) 5.0 or Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. Entity with relative path '../Token/TLA%23tla_mmc_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'.. However, these MIME types have been added to the Microsoft Internet Information Services (IIS) 5.0 or Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. metabase. The following script will display all the MIME types in the Microsoft Internet Information Services (IIS) 5.0 or Entity with relative path '../Token/TLA%23tla_iis60_md.md' can not be found, for source topic '{"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"c6e8c2cb-9ba2-4e75-a0d5-180ec9639433","entity_type":"Article","locale":"en-US"}'. metabase.

' This script lists the MIME types for an IIS Server.  
' To use this script, just double-click or execute it from a command line   
' by calling cscript.exe  
  
dim mimeMapEntry, allMimeMaps  
  
' Get the mimemap object.  
Set mimeMapEntry = GetObject("IIS://localhost/MimeMap")  
allMimeMaps = mimeMapEntry.GetEx("MimeMap")  
  
' Display the mappings in the table.  
For Each mimeMap In allMimeMaps  
    WScript.Echo(mimeMap.MimeType & " (" & mimeMap.Extension + ")")  
Next  

Save the script as a .vbs file (for example, DiscoverIISMimeTypes.vbs) and run it from the command prompt using the following command:

cscript DiscoverIISMimeTypes.vbs

Show: