I am trying to update MIME types in an IIS virtual directory via code. It is
not adding any new type to the system. Any ideas? Is there a way to check if
the MIME types exists before attempting to add it?
CALL SetRequiredIISMimeTypes
'============================================
Sub SetRequiredIISMimeTypes
const strMIME_TYPE_EXT_1 = ".abc"
const strMIME_TYPE_DATA_1 = "text/plain"
const strMIME_TYPE_EXT_2= ".efg"
const strMIME_TYPE_DATA_2 = "application/octet-stream"
'Call procedure to set MIME types.
AddTypeToIIS strMIME_TYPE_EXT_1, strMIME_TYPE_DATA_1
AddTypeToIIS strMIME_TYPE_EXT_2, strMIME_TYPE_DATA_2
End Sub
Sub AddTypeToIIS(strExtension, strMimeType)
Dim objMimeMap
Dim objMimeMapList
Dim lngMimeMapListCount
Const ADS_PROPERTY_UPDATE = 2
' Specify the location in the IIS metabase for the 'MimeMap' node.
' Note: 'MimeMapObj' acts a 'container' object for the 'objMimeMapList'
object.
Set objMimeMap = GetObject("IIS://localhost/W3SVC")
' Use GetEx to retrieve an array of 'MimeMap' objects.
objMimeMapList = objMimeMap.GetEx("MimeMap")
' Create a new 'MimeMap' item in the array.
lngMimeMapListCount = UBound(objMimeMapList) + 1
ReDim Preserve objMimeMapList(lngMimeMapListCount)
Set objMimeMapList(lngMimeMapListCount) = CreateObject("MimeMap")
' Create our new 'MimeType'
objMimeMapList(lngMimeMapListCount).Extension = strExtension
objMimeMapList(lngMimeMapListCount).MimeType = strMimeType
' Use PutEx to UPDATE the MimeMap array with our new array.
objMimeMap.PutEx ADS_PROPERTY_UPDATE, "MimeMap", objMimeMapList
objMimeMap.SetInfo
End Sub
Any help would be appreciated!
--
Primetime
{Coding to the break of dawn}