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

不羁的心 提交于 2019-12-04 09:50:23

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/1015892/is-there-an-enum-for-the-contenttype-property-on-a-httpwebresponse-text-plain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!