Limitation of ModelState.IsValid in ASP.NET MVC 3

岁酱吖の 提交于 2019-12-07 09:04:35

问题


I always use ModelState.IsValid for check all of my model validation validated correctly in Server Side, but I think there is a limitation to use this. For example I define a Remote Validation attribute, but if I disable javascript then ModelState.IsValid don't check Remote Validation and always return true, Where is the problem? this is a limitation for ModelState.IsValid or is my fault? If necessary I can Add all my implementation.


回答1:


This question has come around a few times. The answer is: it doesn't validate on the server-side, you have to perform the validation action yourself. See also following SO posts:

  • asp.net mvc 3 serverside remote validation not working on submit through fiddler
  • RemoteAttribute validator does not fire server-side

Of course, it would be nice to be able to validate it anyway on the server-side. Luckily some nice guy made an implementation for it. You can find his short blog post: http://www.tugberkugurlu.com/archive/asp-net-mvc-server-side-remote-validation .



来源:https://stackoverflow.com/questions/10494168/limitation-of-modelstate-isvalid-in-asp-net-mvc-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!