Runtime: System.Net.Mime.MediaTypeNames missing types

Created on 26 Oct 2017  路  19Comments  路  Source: dotnet/runtime

https://github.com/dotnet/corefx/blob/3f0bd5d8c3d019ad8b1561395030a58bc38ddfe9/src/System.Net.Mail/ref/System.Net.Mime.cs#L44

I tried using System.Net.Mime.MediaTypeNames in my asp net core api to remove "magic strings"

c# [Consumes(System.Net.Mime.MediaTypeNames.Application...)] public IActionResult Post(...) { ... }

But it's missing quite a few MIME types.

These come to mind:

text/css
text/javascript

application/json
application/json-patch+json
application/xml
application/javascript
application/x-www-form-urlencoded

multipart/form-data
multipart/byteranges

image/png
image/bmp
image/webp
image/svg+xml

audio/midi
audio/mpeg
audio/webm
audio/ogg
audio/wav

video/webm
video/ogg

api-suggestion area-System.Net

Most helpful comment

See dotnet/corefx#26201 for application/json and application/xml

All 19 comments

Please implement this already!

See this and this.

See dotnet/corefx#26201 for application/json and application/xml

I'm currently dealing with file uploads.
It would be great to have MIME types for Office documents (Word, Excel).

Perhaps System.Net.Mime.MediaTypeNames will share the same fate as System.Net.HttpStatusCode. Which is that it's considered dead and not to be used.

https://github.com/aspnet/Mvc/issues/6997#issuecomment-384439229

Perhaps System.Net.Mime.MediaTypeNames will share the same fate as System.Net.HttpStatusCode. Which is that it's considered dead and not to be used.

aspnet/Mvc#6997 (comment)

Funny that MediaTypeNames or at least its inner classes are designed more or less the same as StatusCodes, the replacement for HttpStatusCode.

2019 still no application/x-www-form-urlencoded.

Maybe class MediaTypeNames and nested classes as partial?

I don't think you can spread a partial type across multiple assemblies.

This issue has been marked as up-for-grabs, but we still need to wait for the API approval, is that correct?

It's public API so strictly, yes (not sure whether https://github.com/dotnet/corefx/pull/36365 got API approval). @wfurt can share how to best do that eg with a PR.

Let me ask around @danmosemsft. The list here seems more reasonable than dotnet/corefx#36365.

Triage: We are open to add a few of the MIME type enums.
Next step: Create proposal with most used ones (with some links to usage ideally) and with names how they should be exposed.

BTW might of interest to subscribers: https://github.com/dotnet/csharplang/issues/2849

With problemdetails, https://tools.ietf.org/html/rfc7807, implemented in .net core please add:

  • application/problem+json
  • application/problem+xml

@karelz Is there a specific format example you have in mind for this proposal? What restrictions and limitations should someone interested in making a pull request be aware of?

PR is early. We need API proposal first, well thought through as suggested above: https://github.com/dotnet/runtime/issues/1489#issuecomment-537625716
The API proposal info is here: https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md with good examples in form.
Usage data will be key in this one (does not have examples in linked process)

Hello could you please add "application/merge-patch+json" ?

Hi, this seems to be a very simple change, doesn't break anything and adds useful MIME types. Why can't we get this to move forward?

@rjperes see the above discussion: https://github.com/dotnet/runtime/issues/1489#issuecomment-541385535

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noahfalk picture noahfalk  路  3Comments

omajid picture omajid  路  3Comments

jkotas picture jkotas  路  3Comments

yahorsi picture yahorsi  路  3Comments

chunseoklee picture chunseoklee  路  3Comments