'"application/json" constant in .NET framework

I've just declared a constant for the "application/json" content type in one of my classes.

public const string JsonContentType = "application/json";

I'm not sure it is a good practice.

Does .NET framework have a predefined const for "application/json"?



Solution 1:[1]

In order to add an up-to-date answer: since dotnet core 2.1 MediaTypeNames.Application.Json has been defined.

See https://github.com/dotnet/corefx/pull/26701 for the changeset.

Solution 2:[2]

There is now for Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6...

System.Net.Mime.MediaTypeNames.Application.Json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bob Van de Vijver
Solution 2 Mick