Enum returning string value in WebAPI

There is a setting that can be added to a variable, that will return the string value in JSON.

It can either be set on the variable declaration like this:

[JsonConverter(typeof(StringEnumConverter))]
public PositionDto pagePosition { get; set; }

or it can be set globally, like this:

var json = config.Formatters.JsonFormatter;
json.SerializerSettings.Converters.Add(new StringEnumConverter());

if you are using asp.net core use JsonStringEnumConverter instead of StringEnumConverter [JsonConverter(typeof(JsonStringEnumConverter))]