zoukankan      html  css  js  c++  java
  • 解决.Net 4.0 A potentially dangerous Request.Form value was detected from the client 异常

    解决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">

      用户在页面上提交表单到服务器时,服务器会检测到一些潜在的输入风险,例如使用富文本编辑器控件(RichTextBox、FreeTextBox、CuteEditor等)编辑的内容中包含有HTML标记或脚本标记,ASP.NET页面会抛出一个"A potentially dangerous Request.Form value was deceted from the client"的异常。这个是ASP.NET页面为了防范页面注入功能的一种保护机制,要取消这种保护,常规的做法是在.aspx文件的<%@Page %>部分加入ValidateRequest="false"属性。但是从.NET 4.0开始你可能需要多修改一个地方,在网站的web.config文件中加入这行配置:

    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime requestValidationMode="2.0"/>
    </system.web>

       同时,你还需要确保页面上用户输入的部分不会存在任何注入攻击的代码,常用的做法是使用Encode处理。

    http://www.cnblogs.com/wenjie/archive/2011/06/13/2079785.html

    解决升级至.net4后出现A potentially dangerous Request.Form value was detected from the client (转载)

  • 相关阅读:
    js将手机号中间四位变成*
    js判断浏览器客户端类型
    vue项目涉及到的setInterval
    MYSQL 总结——2
    MySQL补充
    PyCharm软件安装
    MYSQL 总结——1
    linux系统通过ssh拉取gitee项目 设置权限
    tp5开源的后台管理系统
    window下Python安装
  • 原文地址:https://www.cnblogs.com/waw/p/3945640.html
Copyright © 2011-2022 走看看