出现错误‘A potentially dangerous Request.Form value was detected from the client’的解决方案
2012-12-24 10:44
489 查看
在ASP.NET中出现A potentially dangerous Request.Form value was detected from the client错误是因为Request时出现有HTML或Javascript等字符串时,系统会认为是危险性值。
解决方案:
在.aspx文件头中加入:
如果是在.Net4.0中,还需要在配置文件中加入以下代码:
在配置文件中加入以下代码:
其他方案:在Controller的Action前面加入[ValidateInput(false)]
如果以上方案都没有效果,那就只能使用终极解决方案:在ViewModel的属性上添加[AllowHtml]
解决方案:
在.aspx文件头中加入:
<%@ Page validateRequest="false" %>
如果是在.Net4.0中,还需要在配置文件中加入以下代码:
<httpRuntime requestValidationMode="2.0"/>
在配置文件中加入以下代码:
<pages validateRequest="false" />但是这样的写法不安全,请慎用。可以指定某些页面不验证:
<location path="Views/News/Edit.ascx"> <system.web> <pages validateRequest="false" /> </system.web> </location>
其他方案:在Controller的Action前面加入[ValidateInput(false)]
如果以上方案都没有效果,那就只能使用终极解决方案:在ViewModel的属性上添加[AllowHtml]
相关文章推荐
- 错误解决:[A potentially dangerous Request.Form value was detected from the client (warning="卡Ć.
- 错误解决:[A potentially dangerous Request.Form value was detected from the client (warning="卡Ć..."). ]
- 错误提示: A potentially dangerous Request.Form value was detected from the client ....
- 处理asp.net出现A potentially dangerous Request.Form value was detected from the client
- .net 4.0 A potentially dangerous Request.Form value was detected from the client 的解决方案
- 尝试获取Cookie时出现的错误提示:"A potentially dangerous Request.Cookies value was detected from the client:
- 解决ASP.NET 4.0 "A potentially dangerous Request.Form value was detected from the client". 错误
- A potentially dangerous Request.Form value was detected from the client 解决方案
- A potentially dangerous Request.Form value was detected from the client(txtTest="<b>").
- 解决.Net 4.0 A potentially dangerous Request.Form value was detected from the client 异常
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client的解决办法
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client 的处理
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client
- A potentially dangerous Request.Form value was detected from the client (txtTest="").
- A potentially dangerous Request.Form value was detected from the client