I have come across a piece of code in my Web API project, which has a class of this structure:
public class QuestionDto
{
public bool disabled {get;set;}
public int id {get;set;}
public int order {get;set;}
public PositionDto pagePosition {get;set;}
public string title {get;set;}
}
public enum PositionDto
{
FullWidth = 0,
Half = 1
}
There is an API call that returns QuestionDto, along the lines of:
[Route("")]
[HttpGet]
[ResponseType(typeof(QuestionDto))]
public async Task<IHttpActionResult> GetCategoryQuestions()
{
return Ok(new QuestionDto { PagePosition = PagePositionDto.Half });
}
Here is a snip from the Chrome console network tab showing the repsonse for this API call:
How can the enum be returning its text value, rather than its int value?
To confuse this even further, if I then take this same class structure and copy and paste to a differrent project, the api call returning this object will return the int value - which is what I would expect.
So how can the first project be returning the string value?
Is there some setting somewhere which can make this enum return its string value?
