我看不出这里出了什么问题。我在顶部有更具体的路线,但它只返回错误 404 - 未找到。
执行/api/playernames/competitions有效,但/api/playernames/teams/competitionid/81bbd23d-54a2-4204-a771-85c48555a992无效。我究竟做错了什么?
routes.MapRoute("PlayerNamesDbTeams", "playernames/teams/competitionid/{competitionId}",
new { controller = "playernames", action = "Teams", competitionId = "" });
routes.MapRoute("default", "{controller}/{action}/{id}",
new { controller = "playernames", action = "Competitions" });
public class PlayerNamesController : ApiController
{
[HttpGet]
public List<Competition> Competitions()
{
using (var service = new AggregatorClient())
{
return service.GetCompetitions();
}
}
[HttpGet]
public List<Team> Teams(string competitionId)
{
using (var service = new AggregatorClient())
{
return service.GetTeams(competitionId);
}
}
}
发出像/api/playernames/teams?competitionId=xxxxxx这样的请求确实有效。