Question

Is there a good way in asp.net MVC to trace ModelState errors? IsValid returns false when I submit my form even if there aren't actually any fields in it, or anything being validated. I looked at this thread here and tried Steve Willcock's suggestion but no exceptions are thrown, just a generic error.

Is there any way I can see what is causing the ModelState to become invalid without stepping through every single part of the model that's used? It's quite large and I was just wondering if there is a more efficient way.

Was it helpful?

Solution

I had this issue and found that in my model I had a unique id of type int that was causing a problem. When I set it to nullable in my model the error went away.

W/out seeing any of your code though it's a bit hard to figure out but the above helped me.

I also noticed that when I was doing validations, using the Nerd Dinner approach, I would sometimes get an error popup saying something like "Value Required". Linked it to the same problem and made all Id's nullable.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top