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/javascriptapplication/json
application/json-patch+json
application/xml
application/javascript
application/x-www-form-urlencodedmultipart/form-data
multipart/byterangesimage/png
image/bmp
image/webp
image/svg+xmlaudio/midi
audio/mpeg
audio/webm
audio/ogg
audio/wavvideo/webm
video/ogg
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 asSystem.Net.HttpStatusCode
. Which is that it's considered dead and not to be used.
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:
@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
Most helpful comment
See dotnet/corefx#26201 for
application/json
andapplication/xml