ashx页面 “检测到有潜在危险的 Request.Form 值”的解决方法(控制单个处理程序不检测html标签)

  如题:

  使用web.config的configuration/location节点.

  在configuration节点内新建一个location节点,注意这个节点和system.webserver那些是平级节点

  然后使用location/@path 来指定某个单独的文件,这个文件可以是aspx也可以是ashx,更加可以是Razor模板的cshtml(当然MVC有Unvalidated方法,用不到这样),

  然后在location下面配置page和httpruntime(4.0)节的属性就OK了.这样就可以做到只影响一个文件而不会覆盖其他文件的ValidateReqeust设置。

  配置如下:

  

 <location path="ashx/dosth.ashx" >
    <system.web>
    <httpRuntime  requestValidationMode="2.0" />
    </system.web>
  </location>

  

  

原文地址:https://www.cnblogs.com/yetiea/p/3894926.html