MVC3.0 从客户端(="...")中检测到有潜在危险的 Request.Form 值。

今天做一个MVC3.0的POST提交测试,

发现在

[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(false)]
public ActionResult Synchronous()
{
      string RequestMsg = Request.Form.ToString();
      return Content("success");
}

这样一个ActionResult 前面加上了  [ValidateInput(false)] 还是会出现  

-- 从客户端(="...")中检测到有潜在危险的 Request.Form 值。-- 这样的错误

记得以前用MVC2.0这样做是不会出这样的错的……

网上找到了一个方法 :

<system.web>
    <httpRuntime requestValidationMode="2.0"/>
</system.web>

在web.config中的system.web 节点中加上一个配置就可以解决这个问题了

但是这样应该是把校验模式改为了2.0的模式,不知道3.0是不是有自己另一种直接对表单进行校验的模式呢?

原文地址:https://www.cnblogs.com/wangbogo/p/2654105.html