我需要将 POST 操作设置为绝对 URL(例如,http://www.cnn.com http://www.cnn.com)。有没有办法使用 Html.BeginForm() 帮助程序并向其传递 url?
BeginForm 方法有几个重载。
为了使用所需的 url 设置表单标签上的操作属性,您需要使用 BeginForm 的以下重载:
BeginForm(String, String, FormMethod, IDictionary<String, Object>)
// here are the parameter names:
BeginForm(actionName, controllerName, method, htmlAttributes)
由于您要发布到外部站点,因此无需设置actionName和controllerName,只需将它们保留为空即可。
@Html.BeginForm(
null, null, FormMethod.Post, new {@action="http://cnn.com/post"}
)
这不会对操作参数进行编码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)