I\'m trying to do create a delete function in my web API class. I had problems earlier with using the Put and Patch Http messages since these were being linked to WebDAV. After
Also wanted to add another answer that someone told me about:
If you have this in your route config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Your id should always be called id and cannot be named something else:
This doesn't work
//api/account/useridvalue
[Authorize]
[HttpDelete]
public IHttpActionResult Delete(string whatEverYourNameis){
//Do delete logic here
Return Ok();
}
This does
//api/account/useridvalue
[Authorize]
[HttpDelete]
public IHttpActionResult Delete(string id){
//Do delete logic here
Return Ok();
}