Html.BeginForm在IE浏览器中发布HttpGet动作而不是HttpPost,在Chrome和Firefox中很好
我的Razor视图中有以下内容:
@using (Html.BeginForm("Edit", "MyController", FormMethod.Post)) { @Html.ValidationSummary(false) @Html.EditorFor(x => x.Role, MVC.Shared.Views.EditorTemplates.KeyValuePairSelectList, new { SelectListOptions = Model.RoleSelectList })
@Html.EditorFor(x => x.Trust, MVC.Shared.Views.EditorTemplates.KeyValuePairSelectList, new { SelectListOptions = Model.TrustSelectList.OrderBy(x => x.Text) })
@Html.EditorFor(x => x.GmcCode)
}
在我的控制器中我有
[HttpGet] public virtual ActionResult Edit(string id) { } [HttpPost] public virtual ActionResult Edit(ViewModel viewModel) { }
在Firefox和Chrome中,一切正常,但在IE中提交表单时,HttpGet操作被触发而不是HttpPost。
调用堆栈或IE开发人员工具控制台中没有线索。
有什么明显我错过了吗?
您的提交按钮应该是一个真实的提交按钮 , type="Submit"
在所有浏览器中正确提交表单。
请参阅此SO问题以获得进一步的差异: 与之间的差异