I faced the same issue although i added [System.Web.Mvc.AllowHtml]
to the concerning property as described in some answers.
In my case, i have an UnhandledExceptionFilter
class that accesses the Request object before MVC validation takes place (and therefore AllowHtml has not effect) and this access raises a [HttpRequestValidationException] A potentially dangerous Request.Form value was detected from the client
.
This means, accessing certain properties of a Request object implicitly fires validation (in my case its the Params
property).
A solution to prevent validation is documented on MSDN
To disable request validation for a specific field in a request (for example, for an input element or query string value), call the Request.Unvalidated method when you get the item, as shown in the following example
Therefore, if you have code like this
var lParams = aRequestContext.HttpContext.Request.Params;
if (lParams.Count > 0)
{
...
change it to
var lUnvalidatedRequest = aRequestContext.HttpContext.Request.Unvalidated;
var lForm = lUnvalidatedRequest.Form;
if (lForm.Count > 0)
{
...
or just use the Form
property which does not seem to fire validation
var lForm = aRequestContext.HttpContext.Request.Form;
if (lForm.Count > 0)
{
...