其他提示

你有没有尝试:

    /*At the Point the ModelState should be Valid(TRUE)
      because we still didn't enforce any validations */
    var v = ModelState.IsValid;

try
    {
        obj.Validate<NetTiersObject>();
    }
    catch (EntityValidationException ex)
    {
        ViewData.ModelState.PopulateWithErrors(ex);
    }

和检查,如果v为真,应该是。 如果是真的,那么obj.Validate<NetTiersObject>();做得不对,因为它的唯一填充错误重复。

  

我的问题是使用时   验证库的方法,它   复制的错误消息。什么时候   只是用模型绑定错误   消息出现奇怪。这些错误   有消息中的属性的名称。

它是奇怪的,因为modelBinding不应填充型号错误,如果你没有使用自定义的模型绑定或试图保存到数据库而无需验证领域至少。

scroll top