Reputation: 5190
If I do the following:
public class CustomRangeAttribute : RangeAttribute
{
public override bool IsValid(object value)
{
return base.IsValid(value);
}
}
The method is executed as expected. If I do:
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
return base.IsValid(value, validationContext);
}
The method is not called. Why? sl3dg3
Upvotes: 1
Views: 2356
Reputation: 77576
This works exactly as you'd expect if you are using ASP.NET MVC 3.0. I tried it myself using your example and it works great -- I get a non-null ValidationContext and it does get invoked. See here for a full elaboration on this. So this suggests yet another reason (beyond the awesome Razor engine) to upgrade to v.3.0.
Upvotes: 2