Is there an enum for the ContentType property on a HttpWebResponse ("text/plain", "application/octet-stream" etc.)?

Content TypeMime TypesHttpwebresponse

Content Type Problem Overview


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.

Content Type Solutions


Solution 1 - Content Type

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

Solution 2 - Content Type

IANA's database is most likely to be complete. Currently, they have the list available in CSV format at https://www.iana.org/assignments/media-types/application.csv. I am assuming this is a stable URL whose content changes as updates are made. If you want to stay up to date, you'd need to put together a mechanism that is appropriate for your needs.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwillView Question on Stackoverflow
Solution 1 - Content TypeChris W. ReaView Answer on Stackoverflow
Solution 2 - Content TypeSinan ÜnürView Answer on Stackoverflow