I get data from MVC and encode it using HttpUtility.HtmlEncode
. The problem is that MVC is not fond of form values containing the ampersand (&) symbol. For example, this...
HttpUtility.HtmlEncode("'");
...results in '
. I fetch it on a GET
, but if I submit this on a POST
, I see the following action error:
Exception = {"A potentially dangerous Request.Form value was detected from the client (selection=\"'...\")."}
How can I encode my data on a GET
in a way that makes MVC happy on a POST
? I cannot set the property to [AllowHtml]
because the model is within a separate class in a 3rd party DLL that I do not have control over, nor can I re-implement it, it seems.