views:

112

answers:

2
+1  Q: 

ASP.NET Validation

Im getting a validation error when a user enters a Foreign name. An example is:

System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl00$pageContent$txtName="Pedro ú logo").

where the ú is being translated as & # 250 ; (without the spaces of course)

These foreign characters are acceptable and should not be causing a validation error. I want ASP.NET validation to validate using UTF-16 and not UTF-8

Many web sites, blogs, and forums say simply to turn off Validation.(ie ValidateRequest="false")

Is there a way around this WITHOUT turning off Validation? Turning off Validation is not acceptable for this application.

Thanks, Jeff

+1  A: 

It's not really possible to tweak request validation mechanism. It's kind of hardcoded. I don't see a reason you don't want to disable it. If you take care of sanitizing and HTML encoding all stuff you get from the user and you want to display on the page (which you should be doing anyway, regardless of ASP.NET request validation), you wouldn't need it much.

Mehrdad Afshari
Great answer. I'm always stumped by the myths around request validation - people always say it opens a potential security hole, but I have yet to see any examples of anyone exploiting it that couldn't be done anyway.
womp
A: 

I've had this problem.

The way around it is to sanitize the input with javascript BEFORE you hit the post.

See This stackoverflow answer to a similar question for some javascript

Also, this is pretty much a duplicate of this stackoverflow question (linked above)

scottschulthess
Thanks to you both