I want to create a custom method in my Web API controller, so rather than just returning all data I can pass in a parameter e.g my controller is called StandingController and I want to create a method called GetStandingsBySeason(string season). I have changed my WebApiConfig to to look like this :
config.Routes.MapHttpRoute(
"DefaultApi",
"api/{controller}/{id}",
new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
"DefaultApiWithAction",
"api/{controller}/{action}/{id}",
new { id = RouteParameter.Optional }
);
And here is the method in my controller :
public IEnumerable<StandingDTO> GetStandingsBySeason(string season)
{
return _repository.GetStandingsBySeason(season).Select(Mapper.Map<StandingDTO>);
}
And in my front end I am calling it like this :
$.getJSON("/api/standing/GetStandingsBySeason/2011", self.standings);
But the method never gets called, can anybody shed any light on what I am doing wrong with this?