The preferred route is actually to include the Id
in the pathinfo since DELETE requests don't have a HTTP Request Body you can submit this info on, e.g:
[Route("/todo/{id}", "DELETE")]
public class DeleteTodo : IReturnVoid
{
public int Id { get; set; }
}
For pragmatic reasons you may want to allow a POST to do the DELETE since browsers my default (and some proxies) don't allow sending of DELETE Requests.
[Route("/todo/{id}/delete", "POST")]
public class DeleteTodo : IReturnVoid
{
public int Id { get; set; }
}
You can simulate a DELETE request in Ajax or jQuery by adding the X-Http-Method-Override HTTP Request header in your Ajax call or as a field in your FormData or QueryString, e.g.
POST /todo/1
X-Http-Method-Override=DELETE
or embedded in the HTML FormData like:
<form action="/todo/1" method="POST">
<input type="hidden" name="X-Http-Method-Override" value="DELETE"/>
</form>
Though it's important not to allow DELETE's via GET as by contract GET's should have no side-effects so are safe to be cached and replayed by HTTP middle-ware like proxies, etc.