I guess that will be a duplicated question because it's something quite basic, but after some search I was not able to find the answer.
I have a .net462 application. I have the following enum:
public enum Test
{
Foo,
Bar,
}
and the following endpoint in one controller:
[HttpGet]
[Route("myTest")]
public IEnumerable<Test> GetMyFooTest()
{
return new List<Test> { Test.Bar, Test.Foo };
}
Now, if I use chrome to retrieve data from the endpoint, I get:
Here the Enums appear in its string form.
However, when I call this endpoint from the front end (JS, jQuery), or if I call it using Postman, I get:
No matter if I visualise it with JSON, XML or any option:
Here I get the numerical values of the Enums.
Why this difference? Is there a way to get the string values in the front end? (of course I have the option to change the controller to return a IEnumerable<string>
and use a ToString()
on the c# side, but that would be quite ugly...).