First time here? Check out the site's "greatest hits" or read a post from the archives. Feel free to leave a comment or ask a question, and consider subscribing to the latest posts via RSS or e-mail. Thanks for visiting!
« XmlFragmentWriter - Omiting the Xml Decl... | Main | It's official - FeedDemon is the Bomb »

Can you add Mime Types to IIS programmatically? KBs say no: http://support.microsoft.com/kb/q142558/

This VBS will though: (Update: This guy did essentially the same thing!)

Dim LocalMimeMap, MimeMap
Dim ExtensionToAdd, MimeTypeToAdd
Dim i
Const ADS_PROPERTY_UPDATE = 2
Set LocalMimeMap = GetObject("IIS://localhost/MimeMap")
MimeMap = LocalMimeMap.GetEx("MimeMap")
ExtensionToAdd = InputBox("Extension:","IIS") 'TODO Take this from the Command Line
MimeTypeToAdd = InputBox("MIME Type:","IIS") 'TODO Take this from the Command Line
i = UBound(MimeMap)+1
Redim Preserve MimeMap(i) 'Make it bigger and maintain its contents
Set MimeMap(i) = CreateObject("MimeMap") 'Add onto the end
MimeMap(i).Extension = ExtensionToAdd
MimeMap(i).MimeType = MimeTypeToAdd
LocalMimeMap.PutEx ADS_PROPERTY_UPDATE,"MimeMap",MimeMap 'Poke it back in
LocalMimeMap.SetInfo



Saturday, August 06, 2005 7:28:41 AM (Pacific Standard Time, UTC-08:00)
Are you sure that this KB says "programatically", I think it says there is no GUI tool for that.
No One
Saturday, August 06, 2005 11:39:11 AM (Pacific Standard Time, UTC-08:00)
OK, valid point. Mostly I was just saving this snippet for when I need it again.
Scott Hanselman
Saturday, August 06, 2005 2:14:44 PM (Pacific Standard Time, UTC-08:00)
This is particularly helpful if you are planning on using ClickOnce to deploy applications from a server that does not have the .NET Framework 2.0 installed. ClickOnce needs two MIME types that are specific to its operation, which are automatically installed if .NET Framework 2.0 is installed, but will not normally be on other web servers.

The settings are for the ".application" and ".manifest" file extensions, and the MIME type for each should be set to "application/x-ms-application."

Of course you can go through the normal IIS configuration tools, but having the script simplifies things.

Comments are closed.

Contact

Sponsors

Hosting By

On this page...

Tags

Calendar

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Archives

Google Ads