I came across this answer How to create an ASP.NET Web API URL? .
Sample code for my answer here on GitHub
You can change your @ Url.RouteUrl code to include both the action name and the "identifier", which is not currently optional for your action route ... perhaps this is why it was not possible to find a match and return an empty string. So try:
var clientUrl = '@Url.RouteUrl("ApiControllerAction", new { httproute="", controller = "Client", action = "clients" id=@... })';
NB. id=@... })'; at the end ... as always, the identifier will be var or property on the model, etc.
Or
You can, of course, just make an optional ID, which will also work:
config.Routes.MapHttpRoute( name: "ApiControllerAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional }
Or
You can find it cleaner to not use the action ... clients could live in their own ClientsController , and you can use the routes and default settings to route it:
routes.MapHttpRoute( name: "ApiControllerAction", routeTemplate: "api/client/clients/{id}", defaults: new { controller="Clients" } );
Then this should give you the required answer:
var clientUrl = '@Url.RouteUrl("ApiControllerAction", new { httproute="", controller = "Clients" })'; //api/client/clients/
and...
var clientUrl = '@Url.RouteUrl("ApiControllerAction", new { httproute="", controller = "Clients", id=@... })'; //api/client/clients/x