The word mime is an abbreviation for
Multipurpose Internet Mail Extensions which is an Internet standard designed for email. What does this have to do with Microsoft's IIS web server you ask? Well mime is also used by other communication protocols such as HTTP, which is where mime crosses paths with IIS. I won't be going any further into the background of
Multipurpose Internet Mail Extensions in this article, and if you wish to read about it in more depth you should have a look at these
Wikipedia and
Mozilla articles. What we will be looking at in this article is how IIS uses mime types, and how you can effectively manage them in your IIS environment.
In a nutshell a mime type is a setting which IIS uses to determine how a particular file type is managed. For instance IIS will have a mime type set for the .html extension which will instruct the client web browser to treat the file as text, while the mime type for an .mpg file is configured as a video file which will require an external application outside the web browser. Windows file associations work in a very similar way. Boiled down it simply is a method that is used so that IIS is able to instruct the client on how to deal with files that are being delivered.
One thing to keep in mind when using mime types on IIS 6 is that unknown mime types will not be served, and the client will be given a 404.3 error message in the web browser. Another thing is that incorrectly configured mime types can lead to incorrect handling of files (ever had your web browser fill up with code like characters when clicking on a link?). For these reasons it is important to make sure you maintain your mime type mappings.
By default IIS comes with the mime types of the most common file types already configured, however you may still need to add more or edit existing ones. Much like the
ScriptMaps property, all the mime types settings are stored in your metabase which by default is a binary file for all versions of IIS apart from IIS 7. The easiest way to find server wide mime type configuration settings is by using adsutil with the following syntax;
adsutil.vbs FIND mimemap
This will search your entire metabase for the
mimemap property which is where all your mime type settings are stored. Once the command has completed you'll be presented with something similar to the following output;
Property mimemap found at:
W3SVC
W3SVC/1/ROOT
MimeMap
From this we can see the
mimemap metabase property exists in three locations on my server. Now lets use adsutil again to see the default mime types set in IIS using this command;
adsutil.vbs ENUM mimemap
This will give you a fairly large list of all the mime types IIS has configured, so if a mime type exists for files you are using there is most likely no need to do anything further unless you would like to alter the way those files are managed. From the output of the first command we can see that there is a
mimemap metabase property set at the root of the default website as indicated by the
W3SVC/1/ROOT string. To see what mime types are configured under this
mimemap property we will use adsutil (yet again) with this command;
adsutil GET W3SVC/1/ROOT/mimemap
This will output a list of all the mime types configured here. Keep in mind that you can configure mime types at a global, site, directory and virtual directory level, and you need to be mindful of how you do this as setting the mime type further down the tree will override the settings at the global level. Likewise if you have a mime type set way down at a virtual directory level and then configure that same mime type at the global level at a later date, then the setting at the global level will override the mime type at the virtual directory level.
Hopefully this article has helped remove some of the mystery of how and why IIS manages some files, but not others. Please feel free to comment or post in the forums if you need any help.
Bookmark/Search this post with: