使用DELETE在Html.BeginForm形式()的方法? [英] Use DELETE form method in Html.BeginForm()?
问题描述
我想可能时使用相应的HTTP方法。在这种情况下,当单击一个按钮来删除一些东西,我想火与属性控制器动作 [HttpDelete]
。不过,我似乎无法使用这方法的表单 - 使用剃刀语法。在 FormMethod
枚举不具有选项删除
和做以下不覆盖它:
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" }))
在搜索解决方案的国债收益率没有,是没有人这样做呢?我知道我可以只使用POST,但不是这个HTTP点删除方法来开始?
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?
推荐答案
您需要在这个表单:
@using (Html.BeginForm("Order", "Users"){
@Html.HttpMethodOverride(HttpVerbs.Delete)
}
这篇关于使用DELETE在Html.BeginForm形式()的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!