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;
newMimeType.MimeType = mimeType;
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.
source
share