我遇到与发布here
相同的问题我有一个<button>
元素,在asp.net MVC中触发“有潜在危险的request.form value ...”错误。例如:
<button type="submit" name="logon" value="ok">Confirm</button>
<button type="submit" name="cancel" value="ok">Cancel</button>
这个javascript(使用jquery UI 1.8.5)
<script type="text/javascript">
$(document).ready(function() {
$("button").button();
});
</script>
问题在于我无法删除name属性(作为我发布的链接中的给定解决方案),因为我捕获了在控制器端按下哪个按钮:
public ActionResult Logon(FormCollection form, string logon, string cancel)
{
if (!string.IsNullOrEmpty(logon))
{
DoLogon();
}
if (!string.IsNullOrEmpty(cancel))
{
Cancel();
}
//etc
}
这有什么解决方法吗?谢谢。请注意,我在IE8或firefox中没有这个问题。
答案 0 :(得分:1)
你见过this吗?
<强>原因强>
.NET框架因为检测到某些内容而抛出错误 在输入的文本中看起来像HTML语句。案文没有 需要包含有效的HTML,只需要打开和关闭 有角度的括号("<...>"
)。
提出的解决方案是在服务器端禁用请求验证:
<pages validateRequest="false" />
请务必仔细阅读警告和解释。