I have a method like this in DeliveryController.cs:
[Route("api/Deliveries/Count")]
public int GetCountOfDeliveryRecords()
{
return _deliveryRepository.GetCount();
}
There are other methods with routes using "Delivery" instead of "Deliveries" which are discovered. But why is the plural of the Controller name also found? Does the Web API routing engine really look first for the API call precisely and then, if not found, look for the singular of that?
IOW, when passed "...api/Deliveries/Count" does it first look for DeliveriesController and, when not found, then search for DeliveryController?
When you apply a Route
attribute directly to a method, the routing engine knows exactly what's the name of the method mapped to that route through reflection and it doesn't try to locate it based on it's name.
When using attribute routing, you can use any naming you want even if you don't respect conventions.
This route would be completely valid:
[Route("api/whatever")]
public int UnrelatedName()
{
return _deliveryRepository.GetCount();
}