一切福田,不離方寸,從心而覓,感無不通。

解决.Net 4.0 A potentially dangerous Request.Form value was detected from the client 异常

本文From hongshengpeng

解决ASP.NET 4.0

"A potentially dangerous Request.Form value was detected from the client". 错误
在.net中,Request时出现有HTML或Javascript等字符串时,系统会认为是危险性值。立马报错。
(在.aspx文件头中加入这句: <%@ Page validateRequest="false" %>,但还是出现相同错误)

或是修改web.config文件:
<configuration>
< system.web>
<pages validateRequest="false" />
< /system.web>
< /configuration>

但错误依旧。
对.NET 4.0, 应该加上requestValidationMode="2.0" to the httpRuntime configuration section of the web.config :
<httpRuntime requestValidationMode="2.0"/>(这句重要)

结构:<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0">