Use DELETE form method in Html.BeginForm ()?

I would like to use the appropriate HTTP method whenever possible. In this case, when the button is pressed to delete something, I want to start the controller action using the [HttpDelete] attribute. However, I cannot create the form using this method - using the Razor syntax. There is no option for Delete in the FormMethod element, and doing the following does not cancel it:

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

Finding solutions gives nothing, nobody does it? I know I can just use POST, but isn't this the start point of the HTTP method to start with?

+7
source share
1 answer

You need this in your form:

 @using (Html.BeginForm("Order", "Users"){ @Html.HttpMethodOverride(HttpVerbs.Delete) } 
+20
source

All Articles