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.
Asked
Active
Viewed 3.0k times
51
![](../../users/profiles/40961.webp)
David d C e Freitas
- 7,146
- 4
- 54
- 66
![](../../users/profiles/99045.webp)
will
- 3,741
- 5
- 31
- 47
-
3Something 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 Answers
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
![](../../users/profiles/84416.webp)
Chris W. Rea
- 5,099
- 36
- 53
-
5It 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.
![](../../users/profiles/100754.webp)
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
-
1I 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