关于表单验证安全的问题

使用FCKeditor后报错:
"从客户端中检测到有潜在危险的 Request.Form 值."
设置了 ValidateRequest="false"后还是报同样错误:

说明: 请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止。该值可能指示存在危及应用程序安全的尝试,如跨站点脚本攻击。若要允许页面重写应用程序请求验证设置,请将 httpRuntime 配置节中的 requestValidationMode 特性设置为 requestValidationMode="2.0"。示例: <httpRuntime requestValidationMode="2.0" />。设置此值后,可通过在 Page 指令或 <pages> 配置节中设置 validateRequest="false" 禁用请求验证。但是,在这种情况下,强烈建议应用程序显式检查所有输入。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkId=153133
英文:

A potentially dangerous Request.Form value was detected from the client (Text="<p>what?</p>").

Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. To allow pages to override application request validation settings, set the requestValidationMode attribute in the httpRuntime configuration section to requestValidationMode="2.0". Example: <httpRuntime requestValidationMode="2.0" />. After setting this value, you can then disable request validation by setting validateRequest="false" in the Page directive or in the <pages> configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case. For more information, see http://go.microsoft.com/fwlink/?LinkId=153133.  Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (Text="<p>what?</p>").

其实是c#的一种表单安全验证机制,建议还是将表单的内容转下码,当然是转成HTML。不转也行,那就找下面两种方法解决吧(二选一)。 

1.要先在web.config文件的system.web节设置:<httpRuntime requestValidationMode="2.0"/>

2.在要验证的页面中的配置加上(头部第一行):validateRequest="false"


转载于:https://my.oschina.net/deanzhao/blog/122878

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值