51

The closest thing I could find was System.Net.Mime.MediaTypeNames but that doesn't seem to have everything (like json) since it seems to be more focused around email attachments.

David d C e Freitas
  • 7,146
  • 4
  • 54
  • 66
will
  • 3,741
  • 5
  • 31
  • 47
  • 3
    Something similar [here](http://stackoverflow.com/questions/10362140/asp-mvc-are-there-any-constants-for-the-default-content-types). People usually deal with it by creating constants as `System.Net.Mime.MediaTypeNames` would never be an exhaustive/complete list. – RBT Jan 09 '17 at 06:42
  • Related post - [What is the correct JSON content type?](https://stackoverflow.com/q/477816/465053) – RBT Feb 28 '19 at 05:03

2 Answers2

28

An enum doesn't make much sense. MIME types are open-ended. That is, the list is not finite: new types are added from time to time.

See RFC4288: Media Type Specifications and Registration Procedures

Chris W. Rea
  • 5,099
  • 36
  • 53
  • 5
    It makes sense to me. Not as part of the .NET framework because that isn't updated frequently (nor should it be). But as a separate library that could be updated as frequently as new types are added (and users of the library cared). Time zones are open-ended too but that doesn't seem to obviate the utility of libraries based on [tz database](http://www.wikiwand.com/en/Tz_database). – Kenny Evitt Jan 08 '15 at 15:56
  • 3
    @KennyEvitt We keep an internal enum for common types we use a lot. Nothing wrong with that. Seems better than magic strings, right? – crush Jun 04 '15 at 20:55
3

IANA's database is most likely to be complete, but you would need to parse those pages to get a flat list.

There is also the mime.types file that comes with Apache which seems to have been derived from the said list.

Sinan Ünür
  • 113,391
  • 15
  • 187
  • 326
  • A flat list is already offered as CSV-file by the IANA's database website. – WΩLLE - ˈvɔlə Dec 19 '13 at 13:55
  • 1
    I parsed the listed on Wikipedia some years ago and generated C#, its here: http://stackoverflow.com/questions/10362140/asp-mvc-are-there-any-constants-for-the-default-content-types – Luke Puplett Jan 15 '15 at 18:35