Asp.net mvc 范围验证程序在ModelState中失败

Asp.net mvc 范围验证程序在ModelState中失败,asp.net-mvc,Asp.net Mvc,以下是我的模型类属性: [Display(Name = "Animation Interval")] [Range(500, 5000, ErrorMessage = "Enter number between 500 to 5000")] public Nullable<decimal> ANIMATION_INTERVAL { get; set; } 当我删除[Range]数据批注时,它开始正常工作,问题在于范围数据批注。我打赌您试图在可为空的字段上

以下是我的模型类属性:

[Display(Name = "Animation Interval")]
      [Range(500, 5000, ErrorMessage = "Enter number between 500 to 5000")]
        public Nullable<decimal> ANIMATION_INTERVAL { get; set; }

当我删除[Range]数据批注时,它开始正常工作,问题在于范围数据批注。

我打赌您试图在可为空的字段上设置范围属性。您不能将某个内容限制在一个范围内,然后允许它为Null——如果使用Required和Null,您会发现类似的问题

if (ModelState.IsValid)
                {
                    _cmsService.AddTile(cms_tile);
                    //return RedirectToAction("Index");
                    return RedirectToAction("Index", new { Mode = "create" });
                }