I have a form that I have been getting submissions that have punctuation and special characters that trigger the potentially dangerous Request.Form value error. I have been trying use the httpUtility.htmlencode and Server.htmlencode method to sanitize textboxes and textareas.
All my tests do not fire because the built-in request validation of the 4.0 framework prevents the code-behind from executing to perform the sanitization. I have included the ValidateRequest in the page header but no matter what I set it too it still does the same thing.
This is the code I have so far.
Session("RequestID") = Server.HtmlEncode(txtRequestID.Value)
Session("FirstName") = Server.HtmlEncode(txtInstFirstName.Text)
Session("LastName") = Server.HtmlEncode(txtInstLastName.Text)
Session("CNumber") = Server.HtmlEncode(txtCNumber.Text)
Session("Email") = Server.HtmlEncode(txtInstEmail.Text)
Session("Phone") = Server.HtmlEncode(txtInstPhone.Text)
Session("Department") = ddlDept.SelectedValue
Session("Location") = ddlLocation.SelectedValue
That did not work so I tried this:
Session("FirstName") = QuoteString(Trim(txtInstFirstName.Text))
Dim sanFN As String = Session("FirstName")
Server.HtmlEncode(sanFN)
What can I do to make this work? According to all the websites I have visited it should work.
Thanks, Tyler
Unfortunately, the project was scrapped and we moved to a new architecture (ruby on rails).