views:

89

answers:

0

I need to write a simple IronPython script to work with MimeTypes within IIS. I have scripts to modify other IIS configurations but can't seem to get any MimeTypes.

The attached script does not return any results. Running the same code within a C# console application produces the desired results.

What do I need to do to get the attached script to return the list of registered mime types for IIS?

import clr

clr.AddReference("System.DirectoryServices")

from System.DirectoryServices import *
from System import *
from System.Diagnostics import *

def log(msg):
    print msg
    Debug.WriteLine(msg)

def updateMimeTypes():
    srvr = DirectoryEntry("IIS://localhost/W3SVC")

    mimeTypes = srvr.Properties["MimeMap"]

    for mimeType in mimeTypes:  
     log("Mime Type: " + mimeType.Extension + " " + mimeType.MimeType) 

try:
    log("Register .manifest mime type as text/cache-manifest")
    updateMimeTypes()

except Exception, ex:
    log(ex.ToString())
    raise ex.Message