Handle query parameters correctly.
I have an API defined, which takes query parameter and depending on the type of query parameter passed, it behaves differently. To be precise it is Asp.Net Web API and it calls different methods/operations depending on the query parameters e.g., below two call will execute different methods of the controller.
/Api/DoSomething?Page=1
/Api/DoSomething?ID=1
It works fine for the first URI but when I call the second URI it passes both the query parameters to it Page and ID, which fails the routing as it doesn't get the match. Of course, value of the Page is passed as null.
I can make this work only by URL rewriting, which doesn't seem to be the elegant way to do it e.g.,
/Api/DoSomething/ByPage?Page=1
/Api/DoSomething/ByID?ID=1