I want to setup routing for my WEBAPI to have few methods with paramater and few without parameters. I want to use my function names in the controller in the actual urls to be used for actions. To explain it more, here is my routing mapping:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
Here are the two functions I add:
[HttpGet]
public List<Category> FunctionWithParam(long param)
{
//return something
}
[HttpGet]
public List<Category> FunctionWithoutParam()
{
//return something
}
When I hit:
root/api/controller name/FunctionWithoutParam
it does call the appropriate function. But I cannot call FunctionWithParam. I tried
root/api/controller name/FunctionWithParam/10
But this does not seem to work. I put a breakpoint and the function with parmater is just not called. What am I doing wrong, How can I get this to work?