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

无人久伴 提交于 2019-12-30 08:01:09

问题


I have one asp.net application, which has some problems while i am entering the special characters such as ": &#, " in the search box. If i enter this text in search box, i got the exception like this.

A potentially dangerous Request.Form value was detected from the client (txtValue=": &#, ").

then i searched on the net, i got one general solution for this that to set the validaterequest to false. But no changes has been made on my application. Please help me for solving this issue. Any response that would be appreciated.


回答1:


Add a web.config containing

<system.web>
    <pages validateRequest="false" />
</system.web>

to the directory with the page that has the form in question.

See http://www.asp.net/learn/whitepapers/request-validation for a complete description.

In case you use asp.net 4.0, you may try

<httpRuntime requestValidationMode="2.0" />

See also

  • ValidateRequest="false" doesn't work in Asp.Net 4
  • ASP.NET 4 Breaking Changes



回答2:


A little late, but in agreement with those saying putting this in web.config is a security hole.

I do it with the [ValidateInput(false)] attribute on the controller in question.

ValidateInput is found in System.Web.MVC in MVC2




回答3:


I created a table article with columns articleId and article_content. I also used html editor for article_content column. When I tried to save I got the same error. It was resolved by adding [AllowHtml] to the article_content property in the class.

Don’t forget to include the namespace using System.Web.Mvc. For more details: http://www.infinetsoft.com/Post/A-potentially-dangerous-Request-Form-value-was-detected-from-the-client/1246




回答4:


Using Framework 4.5 the solution is to modify web.config adding following line:

<httpRuntime requestValidationMode="4.5"/>

And getting the request as follows:

string reportXML = this.Request.Unvalidated.Form["reportstream"];


来源:https://stackoverflow.com/questions/2955364/a-potentially-dangerous-request-form-value-was-detected-from-the-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!