Can anyone provide some insight as to how overload resolution works in MVC Web API?
Let's assume the same HTTP method for all operations, say GET, as that part's clear enough.
Now, let's asume I have a User type with some fields, which include a "UserName" string field.
Now, let's assume I have two operations, one which takes a string "UserName" parameter, and another one taking a User parameter.
Now, if I invoke the controller using a single parameter named "UserName", I get routed to the operation getting the single string. It's the closest match, no problem there.
Now, if I invoke with no parameters, I get routed to the one getting an object. Why? No clue.
Then, if I invoke with either one parameter not called UserName, or with more than one parameter, I get an error saying the call matches both operations. Do operations receiving a complex object somehow produce an operation with a single parameter somehow? Is there a way to pass parameters and have the resolution choose the function receiving the object parameter?
And finally, the FromUri tag.
Using FromUri, the operation doesn't seem to be ever considered for overload resolution. That is, it doesn't matter if I pass an a parameter with a name matching one, or even all of the object's attributes. It will never get matched unless it has its own HTTP method.
Also, if I create an overload with parameters matching the properties of the object in the FromUri tag, I'd expect it to generate an operation with conflicting parameters, but as I said before, the call always resolves to the operation getting the individual parameters, no matter what.
Can anyone clarify? Any help will be appreciated.
Please refrain from suggesting tricks involving specifying custom routes. I'm not trying to achieve anything except understanding the overload resolution behaviour.