One of the annoyances working on the Windows/IIS stack is that getting mime types is a pain. They are located in multiple places and there is no really ideal “best practice” method to get mime types without what I consider overly-complicated solutions. In light of this observation I wrote a basic C# program that fetches the mime.types file from the Apache project and converts it to a C# Dictionary keyed by file extension. It is a basic program but might be useful for others wondering why in the world this is so complicated.
ApacheMimeTypesToDotNet on github
The output looks like this: ApacheMimeTypes.cs
using System;
using System.Collections.Generic;
namespace ApacheMimeTypes
{
class Apache
{
public static Dictionary MimeTypes = new Dictionary
{
{ "123", "application/vnd.lotus-1-2-3" },
{ "3dml", "text/vnd.in3d.3dml" },
{ "3g2", "video/3gpp2" },
{ "3gp", "video/3gpp" },
{ "7z", "application/x-7z-compressed" },
{ "aab", "application/x-authorware-bin" },
{ "aac", "audio/x-aac" },
{ "aam", "application/x-authorware-map" },
{ "aas", "application/x-authorware-seg" },
{ "abw", "application/x-abiword" },
{ "ac", "application/pkix-attr-cert" },
{ "acc", "application/vnd.americandynamics.acc" },
{ "ace", "application/x-ace-compressed" },
{ "acu", "application/vnd.acucobol" },
{ "acutc", "application/vnd.acucorp" },
{ "adp", "audio/adpcm" },
{ "aep", "application/vnd.audiograph" },
{ "afm", "application/x-font-type1" },
{ "afp", "application/vnd.ibm.modcap" },
{ "ahead", "application/vnd.ahead.space" },
{ "ai", "application/postscript" },
{ "aif", "audio/x-aiff" },
{ "aifc", "audio/x-aiff" },
{ "aiff", "audio/x-aiff" },
{ "air", "application/vnd.adobe.air-application-installer-package+zip" },
{ "ait", "application/vnd.dvb.ait" },
{ "ami", "application/vnd.amiga.ami" },
{ "apk", "application/vnd.android.package-archive" },
{ "application", "application/x-ms-application" },
{ "apr", "application/vnd.lotus-approach" },
{ "asc", "application/pgp-signature" },
{ "asf", "video/x-ms-asf" },
{ "asm", "text/x-asm" },
{ "aso", "application/vnd.accpac.simply.aso" },
{ "asx", "video/x-ms-asf" },
{ "atc", "application/vnd.acucorp" },
{ "atom", "application/atom+xml" },
{ "atomcat", "application/atomcat+xml" },
{ "atomsvc", "application/atomsvc+xml" },
{ "atx", "application/vnd.antix.game-component" },
{ "au", "audio/basic" },
{ "avi", "video/x-msvideo" },
{ "aw", "application/applixware" },
{ "azf", "application/vnd.airzip.filesecure.azf" },
{ "azs", "application/vnd.airzip.filesecure.azs" },
{ "azw", "application/vnd.amazon.ebook" },
{ "bat", "application/x-msdownload" },
{ "bcpio", "application/x-bcpio" },
{ "bdf", "application/x-font-bdf" },
{ "bdm", "application/vnd.syncml.dm+wbxml" },
{ "bed", "application/vnd.realvnc.bed" },
{ "bh2", "application/vnd.fujitsu.oasysprs" },
{ "bin", "application/octet-stream" },
{ "bmi", "application/vnd.bmi" },
{ "bmp", "image/bmp" },
{ "book", "application/vnd.framemaker" },
{ "box", "application/vnd.previewsystems.box" },
{ "boz", "application/x-bzip2" },
{ "bpk", "application/octet-stream" },
{ "btif", "image/prs.btif" },
{ "bz", "application/x-bzip" },
{ "bz2", "application/x-bzip2" },
{ "c", "text/x-c" },
{ "c11amc", "application/vnd.cluetrust.cartomobile-config" },
{ "c11amz", "application/vnd.cluetrust.cartomobile-config-pkg" },
{ "c4d", "application/vnd.clonk.c4group" },
{ "c4f", "application/vnd.clonk.c4group" },
{ "c4g", "application/vnd.clonk.c4group" },
{ "c4p", "application/vnd.clonk.c4group" },
{ "c4u", "application/vnd.clonk.c4group" },
{ "cab", "application/vnd.ms-cab-compressed" },
{ "car", "application/vnd.curl.car" },
{ "cat", "application/vnd.ms-pki.seccat" },
{ "cc", "text/x-c" },
{ "cct", "application/x-director" },
{ "ccxml", "application/ccxml+xml" },
...
};
}
}