Asp.net ValidateRequest = false for text field instead of single page?

Is there a way to disable query validation only for certain text fields instead of the entire page? I use Server.HtmlEncode / Decode because users legally use <and>, but I don’t want to use ValidateRequest="false" on the whole page, because someone can add a text box later and forget to avoid typing, in which case I would like the check to be performed so that the error is detected and not vulnerable to html injection.

There seems to be a simple solution, but I was not lucky to find it.

(Webforms not MVC)

+6
validation
source share
2 answers
+2
source share

No, query validation is performed for the entire query and cannot be performed based on element by element. Request validation is enabled by ASP.NET by default and should help those who are not aware of the sanitization of HTML inputs from script attacks. Added a few links below for further reading:

MSDN

fooobar.com/questions/299097 / ...

+3
source share

All Articles