I'm new to model bindingcontext
and can't understand why I keep getting null
on result
As far as I understand I need to implement IUnvalidatedValueProvider
in order to turn off validation (as users are posting html).
public class AccountFormBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
//Cast the value provider to an IUnvalidatedValueProvider, which allows to skip validation
IUnvalidatedValueProvider provider = bindingContext.ValueProvider as IUnvalidatedValueProvider;
var result = provider.GetValue(bindingContext.ModelName,true);
return result.AttemptedValue;
}
}