Reputation: 119
I am using a texteditor TinyMCE for allowing users to enter some long descriptions on my site. The problem is when I try to submit the form, it gives error:
A potentially dangerous Request.Form value was detected from the client.
I understand this is because the texteditor includes paragraph tags and other html tags inside the textarea. How i do solve this problem and store the textarea data in my database?
This is my aspx file code(It has other asp.net controls which i omitted from this code). I am using C# code behind to insert data into database.
<html>
<head>
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
tinymce.init({ selector: 'textarea' });
</script>
</head>
<body>
<textarea name="story" cols="50" rows="15">
</textarea>
</body>
</html>
Upvotes: 1
Views: 1116
Reputation: 119
I got the answer. I set the ValidateRequest="false" and then when i capture the Request.Form value, I just use Server.HtmlEncode to escape the HTML tags. While retrieving the data, I use Server.HtmlDecode to decode and display the html tags and maintain formatting.
Upvotes: 2