Reputation: 2157
I am using a TINYMCE text editor and I want to store text in database.
But when I tried to insert data in database using Insert query I found the error like "A potentially dangerous Request".Form value was detected from the client
TEXT THAT I HAVE WRITTEN IN EDITOR
for that i have used
EncodedString = System.Web.HttpUtility.HtmlEncode(Request.Form["txtcontent"]);
But it doesn't encode the tag..
Upvotes: 1
Views: 4136
Reputation: 4054
First off, I'd recommend using a Model
binding instead of Request.Form[]
.
For the actual question at hand, you'd want to add the AllowHtmlAttribute
to the property which has the HTML.
Example View Model
public class MyViewModel
{
public string Name {get;set; }
[AllowHtml]
public string Content { get; set; }
}
Upvotes: 3