How can I make a method with two parameters using ASP.NET Web Api?
So that I can call it like localhost/controller/param1/param2
You can also call the url with specific params names in the querystring:
/api/actions?param1=5¶m2=1/1/2000
Then the controller method would be:
GetByParams(int param1, DateTime param2)
I think the easiest way is to simply use AttributeRouting.
[Route("api/YOURCONTROLLER/{paramOne}/{paramTwo}")]
public string Get(int paramOne, int paramTwo) {
return "The [Route] with multiple params worked";
}
The {} names need to match your parameters.