To add to the master mime type list:
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 reference to :
'System.DirectoryServices' on the .NET add references tab
'Active DS IIS Namespace Provider' on the COM add references tab.
To configure a mime type for a specific site, change ..
'IIS://Localhost/MimeMap'
to
'IIS://Localhost/W3SVC/[iisnumber]/root'
...replacing '[iisnumber]'
with the IISNumber of the website.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…