I'm facing a weird problem when using a list of Enum in an ASP.NET Core 7 Web API .
The client and server side each have the same copy of an Enum class. The formated value of the Uri created by the client is
api/ApiName/?Id=57&ListEnum=EnumVal1,EnumVal2,EnumVal3
On the Web API side, the controller is defined as:
public async Task<ActionResult> ApiName([FromQuery] int Id, [FromQuery] List<EnumName> ListEnum)
When called however, the Web API is not getting all the values. In fact, there is only one item in the list and it's not even the correct value. Like EnumVal4.
I have the JsonStringEnumConverter added in the services :
builder.Services.AddControllers()
.AddJsonOptions(opt => { opt.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); });
Is there a way to keep the enum and have things working properly?

[FromQuery(Name = "ListEnum")]. You could also use custom model binding for better deserialization control. Verify that both client and server have identical Enum definitions. Use tools like Postman to test the API and rule out client-specific issues. Make sureJsonStringEnumConverteris set up correctly.