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
Next

Published Friday, September 15, 2006 12:43 AM by steve schofield
Filed under:

Comments

# Useful IIS7 Scripts from the Community

Monday, September 18, 2006 7:57 PM by BillS' IIS Blog

Steve Schofield has been blogging up a storm about IIS7, ever since he deployed www.iislogs.com on IIS7