ASP.NET mvc 2 Validation Always Shows Errors on Page Startup

I searched and honed this problem a lot before this case: I use the PRG template, pragmatically use the same DTO for my messages / receive actions. It seems like when I have dto with data annotation attributes in the get action parameter list, the check always displays errors every time the initial page loads.

In some cases, this may be desirable behavior if you put asterisks in the error message, but how can I get rid of it?

Thanks in advance.

+7
asp.net-mvc-2
source share
1 answer

You need to clear the model state with a call to modelstate.clear () in your action.

+7
source share

All Articles