Ok so a typical route might look like this:
{controller}/{action}/{id}
The problem is that our existing endpoints look like this
{controller}/Somesortofgrouping/{action}
On example of this is our payments controller. We might have the following endpoints:
payment/credit/sale
payment/credit/refund
payment/cash/sale
And the method names would be, respectively:
CreditSale();
CreditRefund();
CashSale();
So rather than having to add every endpoint to the WebApiConfig in order to preserve our convention, is there any way use a template to work with this scenario?
Instead of adding every endpoint to the config, you may consider using the excellent AttributeRouting package and configure routes on the controller/actions itself using attributes.
Some restrictions apply to Web API (as listed in the documentation) as compared to MVC.
After having used this library, it’s difficult to imagine going back to maintain a separate configuration of routes.