Can I configure the IIS MIME type in .NET?

Can I configure my own MIME type via ASP.NET or some .NET code? I need to register the Silverlight XAML and XAP MIME types in IIS 6.

+5
source share
2 answers

To add to the list of basic mime types:

using (DirectoryEntry mimeMap = new DirectoryEntry("IIS://Localhost/MimeMap"))
{
    PropertyValueCollection propValues = mimeMap.Properties["MimeMap"];

    IISOle.MimeMapClass newMimeType = new IISOle.MimeMapClass();
    newMimeType.Extension = extension; // string - .xap
    newMimeType.MimeType = mimeType;   // string - application/x-silverlight-app

    propValues.Add(newMimeType);
    mimeMap.CommitChanges();
}

Add a link to:

'System.DirectoryServices' on the Add Links tab in the .NET "Active DS IIS Namespace Provider" on the Add Links tab.

To configure the mime type for a specific site, change ..

'IIS://Localhost/MimeMap'

to

'IIS://Localhost/W3SVC/[iisnumber]/root'

... replacing '[iisnumber]'with the IISNumber of the website.

+6
source

" Active DS IIS" COM.

, IIS .

. MIME , ?

+1

All Articles