Question

I'd like to use the appropriate HTTP method when possible. In this case, when a button is clicked to delete something, I want to fire the controller action with the attribute [HttpDelete]. However, I can't seem to create a form with this method - using Razor syntax. The FormMethod enum does not have an option for Delete and doing the following doesn't override it:

@using (Html.BeginForm("Order", "Users", FormMethod.Post, new { method = "DELETE" }))

Searching for solutions yields none, is nobody doing this? I know I can just use POST but isn't this the point of the HTTP delete method to begin with?

Was it helpful?

Solution

You need this in your form:

@using (Html.BeginForm("Order", "Users"){ 
   @Html.HttpMethodOverride(HttpVerbs.Delete)
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top