IIS7 – post #9 – Reading MIME Types w/code

I try to visit as many IIS7 places as possible.  One item mentioned not in the IIS7 GUI is how to add MIME types.  Well, I couldn't figure how to add them but I can 'read' them from my Vista RC1 machine.  How to add will be in another posting.  This code below doesn't build a list, but gives the basics for reading the values stored in the applicationHost.config file.  Happy IIS7 geeking!

Dim sm As New Microsoft.Web.Administration.ServerManager()
Dim appHostConfig As Configuration = sm.GetApplicationHostConfiguration()
Dim section As ConfigurationSection = appHostConfig.GetSection("system.webServer/staticContent")

For Each element As ConfigurationElement In section.GetCollection()
        Dim fileExtension As String = element.Item("fileExtension").ToString
        Dim mimeType As String = element.Item("mimeType").ToString

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: