I have a custom IValueProvider that I wrote to handle json values. It is registered in the globa.asax via
ValueProviderFactories.Factories.Insert(0, new JsonValueProviderFactory());
It works fine, but I just recently needed to post a model back that contains HTML. By default this spawns the old
A potentially dangerous Request.Form value was detected from the client
Error message. It looks like the way to get around that normally is to decorate the model property with an AllowHtml attribute. The problem is my value provider is still throwing the error. Any idea how to get my value provider to respect the AllowHtml attribute?
Here is the relevant code:
public class JsonValueProvider : IValueProvider, IValueDeserializer
{
private ControllerContext context;
public JsonValueProvider(ControllerContext controllerContext)
{
this.context = controllerContext;
}
public bool ContainsPrefix(string prefix)
{
return context.HttpContext.Request.Form.AllKeys.FirstOrDefault(i => i.StartsWith(prefix)) != null; //<!------- The error is thrown here
}
.....