私は次のURLを持っています:
localhost / api / machine / somecode / all
私は次のコントローラーを持っています:
public class MachineController : ApiController
{
public IEnumerable<Machine> Get()
{
return new List<Machine>
{
new Machine
{
LastPlayed = DateTime.UtcNow,
MachineAlertCount = 1,
MachineId = "122",
MachineName = "test",
MachinePosition = "12",
MachineStatus = "test"
}
};
}
public IEnumerable<Machine> All(string code)
{
return new List<Machine>
{
new Machine
{
LastPlayed = DateTime.UtcNow,
MachineAlertCount = 1,
MachineId = "122",
MachineName = "test",
MachinePosition = "12",
MachineStatus = "test"
}
};
}
}
および次のルート:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "MachineApi",
routeTemplate: "api/machine/{code}/all"
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
しかし、何らかの理由でそれは解決していません-明白な理由は何ですか?