Reputation: 2488
I have a Controller called QuotaController, and i can access it via httprequests, like this:
localhost:12345/quota/
What i want is to put an endpoint somewhere so i can access it like:
localhost:12345/quota/increment
or
localhost:12345/quota/decrement
How can this be done?
Upvotes: 4
Views: 2499
Reputation: 1039498
You could change your web api route definition to allow passing an action name:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
And then:
public class QuotaController : ApiController
{
public void Increment()
{
...
}
public void Decrement()
{
...
}
}
Upvotes: 5