0

I have a method in ExtJS that sends to a C# method. On the ExtJS the user is using a button to delete a record. The C# method than deletes the record in the database. When I use [HttpPost] in front of the C# method it works, when I changed to [HttpDelete] I get a "NetworkError: 405 Method Not Allowed - http://localhost:5708/api/record" error.

Here is my C# method

    [HttpDelete]
    [Route("api/record")]

    public async Task<IHttpActionResult> Deleterecord(int recordInt)
    {

    }

Here is my ExtJS listener

  onClickDeleteButton: function () {
    var viewRecord = this.getViewRecord();
    var viewForm = this.getViewForm();
    if (viewRecord && viewForm) {
      viewForm.updateRecord();
      viewForm.submit({
        url: 'api/record',
        method: "DELETE",
        waitMsg: 'Deleting Record...',
        scope: this,
      });
    }
  },

Why is this not working when I use HTTPPost but not HTTPDelete?

Aaron
  • 4,380
  • 19
  • 85
  • 141
  • 2
    This [answer](http://stackoverflow.com/questions/2153917/how-to-send-a-put-delete-request-in-jquery) may help you. Also this http://stevemichelotti.com/resolve-404-in-iis-express-for-put-and-delete-verbs/ – Kosala W Jan 08 '16 at 01:10
  • Can you open the network tab in your browser and look at the response? Particularly the headers `Allow` value. Does it include the `DELETE` method? If not, you may have to configure it in your web.config. – Rob Jan 08 '16 at 02:01

0 Answers0