modelstate.isvalid false
http://stackoverflow.com/questions/1791570/modelstate-isvalid-false-why
第一个
About "can it be that 0 errors and IsValid == false": here's MVC source code fromhttp://aspnet.codeplex.com/sourcecontrol/changeset/view/23011?projectName=aspnet#266501
public bool IsValid { get { return Values.All(modelState => modelState.Errors.Count == 0); } }
Now, it looks like it can't be. Well, that's for ASP.NET MVC v1.
第二个
As you are probably programming in Visual studio you'd better take advantage of the possibility of using breakpoints for such easy debugging steps (getting an idea what the problem is as in your case).
Just place them just in front / at the place where you check ModelState.isValid and hover over the ModelState.
Now you can easily browse through all the values inside and see what error causes the isvalid return false.
可以直接用lambda表达式把错误筛选出来ModelState.Values.Select(x=>x.Errors).Where(x=>x.Count>0)
相关文章
- 在Python中什么样的对象布尔(bool)值为False,什么样的对象布尔(bool)值为True【可以用内置函数bool()判断对象的布尔值】
- setLenient(true/false)
- !"false"==fasle
- 发布网站时应该把debug设置false
- 《JavaScript启示录》——1.8 null、undefined、"string"、10、true和false等原始值不是对象
- tidb导入大量数据报错:statement count 5001 exceeds the transaction limitation, autocommit = false
- JS中的0,null,undefined,[ ],“ ”,false之间的关系
- std::ios::sync_with_stdio(false);
- kubectl apply -f --record 是否将当前创建对象创建命令保存到Annotation注解中中。 --save-config 是否将当前创建配置信息保存到Annotation中,布尔类型true或者false.
- Java8使用@sun.misc.Contended避免伪共享(False Sharing)
- [Browsable(false)]
- useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true 等一些Mysql JDBC Url参数说明