自定义 asp.net mvc 验证错误消息

Customize asp.net mvc validation error message

我创建了这个模型class:

 public class test5
{
    [Required] //when title field empty send from client this is show this messae" The title field is required."
    public string title { get; set; }
    public int content { get; set; }
}

我想将 Required filed 错误消息编辑为自定义消息,当我使用 [Required] 之类的验证时,可以在任何地方显示该错误消息。我该怎么做?

在数据标注中使用关键字Error Message

public class test5
{
[Required(ErrorMessage = "CUSTOM ERROR MESSAGE")]
    public string title { get; set; }
    public int content { get; set; }
}