0

I have Model where some specific fields are decorated with:

AllowHtml

Although that should let that a form field with html input submitted but instead i get this error.

A potentially dangerous Request.Form value was detected from the client (Topic=p style=box-sizing...").

What am I missing here? help please...

Dawar
  • 99
  • 3
  • 14
  • 1
    This may help yuo: https://stackoverflow.com/questions/17254354/asp-net-mvc-a-potentially-dangerous-request-form-value-was-detected-from-the-cli – Beginner May 23 '17 at 13:26

2 Answers2

0

By default, the ASP.NET MVC framework checks requests during model binding to determine whether they contain potentially dangerous content as HTML markup. If HTML is detected, model binding throws an error. If a property is marked with the AllowHtmlAttribute attribute, the ASP.NET MVC framework skips validation for that property during model binding.

Source : https://msdn.microsoft.com/en-us/library/system.web.mvc.allowhtmlattribute(v=vs.118).aspx

As per above defintion, you shouldnt get the error if you have properly used the AllowHtml attribute:

Best Example :

https://www.aspsnippets.com/Articles/What-is-AllowHtml-attribute-its-Uses-and-Examples-in-ASPNet-MVC.aspx

Hope the above link will surely helpful for you,Kindly let me know your thoughts or feedbacks.

thanks

karthik

Karthik Elumalai
  • 1,574
  • 1
  • 11
  • 12
0

You have to just add [ValidateInput(false)] attribute above your controller. This attribute to allowing all HTML

 [HttpPost]  
 [ValidateInput(false)]
 public ActionResult AddAgreement(AgreementsModel model)
 {
    //Your code here
 }
Mukesh Salaria
  • 3,345
  • 1
  • 16
  • 21