Override Message “the value {0} is invalid for {1}” in case of int in WebAPI
问题 I have a variable name CountryId (Integer Type). If user provides a string or any random input to CountryId , the In-built DefaultBindingModel in ASP.Net throws an error : The value '<script>gghghg</script>' is not valid for CountryId. I want to override this message and provide my own text if the ModelState fails. I want a generic solution. I've searched and tried many solutions, but they only worked for MVC applications, not webAPI . public class IntegerModelBinder : DefaultModelBinder {