public class MyModel{ public int? Test { get; set; } = 10; public IEnumerable<string> Sections { get; set; } = Array.Empty<string>();}[ApiController][Route("[controller]")]public class TestController : ControllerBase{ [HttpGet] public ActionResult<MyModel> Test([FromQuery] MyModel model) { return Ok(model); }}
public class MyModel{ public int? Test { get; set; } = 10; public IEnumerable<string> Sections { get; set; } = Array.Empty<string>();}[ApiController][Route("[controller]")]public class TestController : ControllerBase{ [HttpGet] public ActionResult<MyModel> Test([FromQuery] MyModel model) { return Ok(model); }}
The
https://localhost:5001/test?Test=3&Sections=USER
https://localhost:5001/test?Test=3&Sections=USER
resolves to
{"test":3,"sections":[]}
{"test":3,"sections":[]}
, but if I remove default value for a
Sections
Sections
property it resolves to
{"test":3,"sections":["USER"]}
{"test":3,"sections":["USER"]}
. Why behavior is different from int default value?