【发布时间】:2019-01-16 21:58:48
【问题描述】:
有没有办法告诉ASP.NET MVC:
不在某个验证属性失败时继续验证其余验证属性?
然后,还要继续进行其余的验证属性,而不管特定属性是否失败?无论如何,这似乎是默认行为。
例如
[MaxLength(200)] // don't go ahead with the next
// validation attribute applied, i.e. the
// RegularExpressionAttribute below if this one
// fails, since there really would be no point in
// doing that.
[RegularExpression(...)]
public string MyProperty { get; set; }
然后有时也以另一种方式配置它,即不告诉是短路,这似乎是目前的默认行为,如下所示:
[MaxLength(200)] // sure, go ahead with the next one
// even if this one fails
[RegularExpression(...)]
public string MyProperty { get; set; }
基本上,我的问题和this unanswered question差不多。
我正在使用面向 .NET 框架 4.5.2 的 ASP.NET MVC 5.2.7。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-5 data-annotations