在Request的时候,如果出现HTML代码或者JS代码的时候,系统会认为这是不安全的,就会报错“从客户端中检测到有潜在危险的Request.Form 值”。
但是我们在项目中往往需要报错HTML和JS代码,那么就需要进行一下设置:
配置文件(Web.config)配置:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 <system.web> 2 <pages validaterequest="false"/> 3 </system.web>
修改页面的文档头部,设置:ValidateRequest="false"
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoticeAdd.aspx.cs" Inherits="CUTT.Web.SPUI.IframeUI.Notice.NoticeAdd" ValidateRequest="false" %>
通过上述配置如果还是报错,那么再修改一下配置文件:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 <httpRuntime requestValidationMode="2.0" />
大功告成,现在就不用担心报错了。