Here’s my situation
[Route("/Test")]
public class Dto
{
public string[] Companies { get; set; }
}
If I do a GET “/Test?Companies=Microsoft,Tesla”
You can understand that as two different companies. Makes sense! But what if I do this?
GET “/Test?Companies=My Company, LLC”
That’s definitely not two separate companies.
Two solutions I see:
-
Split arrays into multiple parameters like this, and each parameter is considered an individual item:
GET “/Test?Companies=Microsoft&Companies=Tesla” -
Well, same thing as #1 but in a different URL format which I’ve seen other web servers use:
GET “/Test?Companies[]=Microsoft&Companies[]=Tesla”
The 3rd solution I don’t love. I’ve seen it referenced here before, which is how to pass complex data for a GET request using JSV.
And the 4th solution would be to use POSTS, which I also don’t like!
Thoughts on how to properly handle this? Are there settings I can use to handle querystrings properly?