I’m working on a form to allow users to submit a request to our help desk system.
I recently had a user cut and paste some text from a work document into a text field. It had some bolded text in it, so then it caused the form to crash.
“System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client”
Here is a snipped of the code, I’m trying to html encode it, but I must not have the syntax correct since I am still getting the error if I put some simple <b> strong</b> tags in the text field to deal with this problem gracefully.
[SIZE=2]
[/SIZE]
[SIZE=2]MessageBody = MessageBody & [COLOR=#a31515][COLOR=#a31515]"<strong>Application Name: </strong> "[/COLOR][/COLOR] & txtApplicationName.Text & [COLOR=#a31515][COLOR=#a31515]"<br/>"
[/COLOR][/COLOR][/SIZE][SIZE=2]MessageBody = MessageBody & [COLOR=#a31515][COLOR=#a31515]"<strong>Existing Application Group:</strong> "[/COLOR][/COLOR] & txtExistingApplicationGroup.Text & [COLOR=#a31515][COLOR=#a31515]"<br/>"
[/COLOR][/COLOR][/SIZE][SIZE=2]MessageBody = MessageBody & [COLOR=#a31515][COLOR=#a31515]"<strong>Rack Location:</strong> "[/COLOR][/COLOR] & txtRackLocation.Text & [COLOR=#a31515][COLOR=#a31515]"<br/>"
[/COLOR][/COLOR][/SIZE][SIZE=2]MessageBody = MessageBody & [COLOR=#a31515][COLOR=#a31515]"<strong>Additional Comments / Requirements:</strong><br />"[/COLOR][/COLOR] & Server.HtmlEncode(txtAdditionalRequirements.Text) & [COLOR=#a31515][COLOR=#a31515]"<br/><br/></span>"
[/COLOR][/COLOR][/SIZE][SIZE=2]
[/SIZE]
If anyone can see what it is I am doing wrong, It would be much appreciated.
I know I can disable the form validation for the complete page, but I do not want to do that.