A few days ago, while working on an ASP.NET 4.0 Web project, I got an issue. The issue was, when user enters non-encoded HTML content into a comment text box s/he got something like the following error message:

"A potentially dangerous Request.Form value was detected from the client".

This was because .NET detected something in the entered text which looked like an HTML statement. Then I got a linkRequest Validation, that is a feature put in place to protect your application cross site scripting attack and followed accordingly.

To disable request validation, I added the following to the existing "page" directive in that .aspx file.

ValidateRequest="false"

But I still got the same error. Later I found that, for .NET 4, we need to add requestValidationMode="2.0" to thehttpRuntime configuration section of the web.config file like the following:

<httpRuntime requestValidationMode="2.0"/>

But if there is no httpRuntime section in the web.config file, then this goes inside the <system.web> section.

If anyone wants to turn off request validation globally for a user, the following line in the web.config file within<system.web> section will help:

<pages validateRequest="false" />  

Note: But always avoid the last example because there is a huge security issue. The request validation feature in ASP.NET provides a certain level of default protection against cross-site scripting (XSS) attacks.

However, we recommend that you analyze any request validation errors to determine whether existing handlers, modules, or other custom code accesses potentially unsafe HTTP inputs that could be XSS attack vectors.

ASP.NET 4.0 potentially dangerous Request.Form value was detected的更多相关文章

  1. A potentially dangerous Request.Form value was detected from the client问题处理

    问题剖析: 用户在页面上提交表单到服务器时,服务器会检测到一些潜在的输入风险,例如使用富文本编辑器控件(RichTextBox.FreeTextBox.CuteEditor等)编辑的内容中包含有HTM ...

  2. 自己留存:小经验在asp.net 4.5或者asp.net mvc 5解决A potentially dangerous Request.Form value was detected from the client

    以前的解决办法是 <configuration>    <system.web>        <pages  validateRequest="false&q ...

  3. 解决.Net 4.0 A potentially dangerous Request.Form value was detected from the client 异常

    在web.config中加入 <httpRuntime maxRequestLength="22000" executionTimeout="43200" ...

  4. A potentially dangerous Request.Form value was detected from the client

    提交表单中包含特殊字符如<script>可能被认为是跨站攻击代码:解决方法很多,如stackoverflow上的web.config中加设置的方法不中肯[如原贴中Jamie M所说],主要 ...

  5. A potentially dangerous Request.Form value was detected from the client的解决办法

    网上找了这么多,这条最靠谱,记录下来,以备后用 <httpRuntime requestValidationMode="2.0"/> <pages validat ...

  6. [BILL WEI] A potentially dangerous Request.Path value was detected from the client 异常处理办法

    我们在ASP.net中使用URL导向后, 我们在访问某个地址,或者打开某个系统页面的时候,就会报错误: A potentially dangerous Request.Path value was d ...

  7. A potentially dangerous Request.Path value was detected from the client异常解决方案

    场景: 当URL中存在“<,>,*,%,&,:,/”特殊字符时,页面会抛出A potentially dangerous Request.Path value was detect ...

  8. ASP.NET 4.0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F

    System.Web.HttpRequestValidationException: A potentially dangerous Request.F 在使用类似eWebedtior 拷贝内容进去的 ...

  9. System.Web.HttpRequestValidationException: A potentially dangerous Request.F

    ASP.NET .0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F System.W ...

随机推荐

  1. 解决Win7下打不开chm文件的方法

    win7 无法打开chm操作如下:1,在命令行运行regsvr32 itss.dll2,在命令行运行regsvr32 hhctrl.ocx

  2. iPad应用开发者的建议

    原文摘自Smashing Magazine<A Dad’s Plea To Developers of iPad Apps For Children> 我花了很长时间为孩子购买和测试iPa ...

  3. centos 安装PGSQL

    centos 安装PGSQLCentOS下yum安装PostgreSQL目录 1 Configure YUM repository2 Install PGDG RPM file3 Install Po ...

  4. JBoss 系列四十八:JBoss 7/WildFly 使用TCP构建集群

    我知道JBoss 集群Default 的设定就是UDP(JGroups),但在实际环境中的网络环境时常不允许UDP,在这种情况下,我们就需要使用TCP. JBoss 7/WildFly 中负责集群的主 ...

  5. .NET Socket TCP 50W在线连接交互测试

    在平常的交流中经常有人问.net socket能支持多少在线?和C++或linux下比起来应该差很远吧?其实产生这样问题的主要原因是.net很少人去做这方面的测试,而在linux下则经常听到什么100 ...

  6. IMP-00038:无法转换为环境字符集句柄

    参考解决方案:http://www.cnblogs.com/wangsaiming/p/4947151.html

  7. CentOS Minimal版最小化安装后VMware联网详解

    最近想搞个mailman邮件列表,又不想在我常用的CentOS 6.4上做实验,怕破坏了环境,于是就想装个试验机,又嫌它占空间太大,于是找了半天发现CentOS 6.0的minimal版本最适合了,装 ...

  8. Js中的一个日期处理格式化函数

    由于在工作中,经常需要对日期进行格式化,不像后端那样,有方便的方法可调用,可以在date的对象prototype中定义一个format方法,见如下 //日期时间原型增加格式化方法 Date.proto ...

  9. javaweb回顾第七篇jsp

    1:为什么会有JSP jsp全名(java server pages)中文叫做java服务器页面.在Servlet那一篇我们发现用Servlet可以生成动态页面,但是我们却在Servlet中却写了大量 ...

  10. (谷歌浏览器等)解决css中点击input输入框时出现外边框方法【outline:medium;】

    问题:在使用谷歌浏览器,360浏览器时,点击input输入框会出现带颜色的外边框,如下图所示: