Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将 [MaxLength(value)] 用于具有 [EmailAddress] 属性的视图模型电子邮件地址字段。并发现该电子邮件具有 value+1 个字符的路径验证过程。
为此目的尝试 StringLength 属性。
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] public string Email{ get; set; }