I have a form where the user can enter some html content to the HtmlContent property. I use AllowHtml attribute to allow for that kind of content:
[AllowHtml]
public string HtmlContent { get;set; }
When user submits the form and it's valid, everything is ok. But if there are thrown some exceptions in controller during saving, even if there is a try...catch
statement:
public void Save(Model viewModel)
{
try
{
// let's say that an exception is thrown here
Save();
}
catch(Exception exception)
{
// I should be able to catch here the exception that was thrown above
ModelState.AddModelError("", "Error");
}
return View();
}
I always receive the same exception related to my HtmlContent property:
A potentially dangerous value was detected from the client
Which is wrong, because I put AllowHtml attribute.