调用Html.BeginForm并指定操作
问题描述:
我一直在尝试执行以下操作,但是无论如何,我都会不断遇到不同的错误:
I have been trying to do the following but whatever I try I just keep getting different errors:
@using (Html.BeginForm(Url.Action(this.ViewContext.RouteData.Values["action"] as string)))
例如,这产生了:
<form action="/adminTests/create?Length=22" method="post">
有人知道怎么做吗?
答
您正在使用
或: ,或者如果您想生成到当前网址的POST表单,请简单地使用(请注意,这将包括任何查询字符串参数): or if you want to generate a form POSTing to the current url use simply (note that this will include any query string parameters): 有关可用重载的完整列表,请参考文档. For full list of available overloads consult the documentation.@using (Html.BeginForm(ViewContext.RouteData.Values.GetRequiredString("action"), ViewContext.RouteData.Values.GetRequiredString("controller"))))
@using (Html.BeginForm())