2

When I try to add a text like <p>example</p> to Product_Text cell of a product in Tbl_Product, I receive this message: A potentially dangerous Request.Form value was detected from the client.

Although I put <httpRuntime requestValidationMode="2.0" /> and <pages validateRequest="false" /> to <system.web> in web.config, I am continuing to receive the error message.

tereško
  • 57,247
  • 24
  • 95
  • 149
Arya
  • 81
  • 1
  • 8

1 Answers1

1

You need to use HtmlEncode when inserting html into the database. So something like:

var productText = Server.HtmlEncode("<p>example</p>");

in your code behind should work.

sthurston
  • 81
  • 2
  • this looks like a solution. – Arya Sep 14 '19 at 11:15
  • That error should have absolutely nothing to do with encoding the HTML when inserting into the database since that error happens on the form submit, NOT internally when saving to the DB. – Charles Boyung Jan 05 '22 at 21:22