How to replace standard DataAnnotations error messages
问题 I'm using System.ComponontModel.DataAnnotations to validate my model objects. How could I replace messages standard attributes (Required and StringLength) produce without providing ErrorMessage attribute to each of them or sub classing them? 回答1: Writing new post because I need more formatting than comments provide. Look at ValidationAttribute - base class of validation attributes. If validation error occured, error message will be created by method: public virtual string FormatErrorMessage