我想让我的表单执行 Get 而不是 Post(这是用户提交的查询字段)
我知道我可以做到
<% using(Html.BeginForm(action, controller, FormMethod.Get) {%>
但是,我宁愿不必指定操作/ Controller ,并且似乎不存在仅采用 FormMethod 的重载。
这是 MVC 1.0(并且没有 future )
最佳答案
框架中没有这样的重载。但是,如果您将操作和 Controller 作为 null
发送,框架将执行您想要的操作。如果您不喜欢这样,您可以自己创建该扩展:
public static MvcForm BeginForm(this HtmlHelper htmlHelper, FormMethod method) {
return htmlHelper.BeginForm(null, null, method);
}
关于asp.net-mvc - 如何使用 Html.BeginForm 设置 FormMethod.Get,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2228937/