7

I've searched around a lot, and honed this problem down to this case: I'm using the PRG pattern, pragmatically I'm using the same DTO for my post/get actions. It looks like when I have the dto with the data annotation attributes in the get action parameter list, the validation is always displaying errors, every time on initial page load.

In some cases this could be desired behavior if you put asterisks in the error message, but how do I get rid of it?

Thanks in advance.

1
  • 1
    This problem and solution also apply to MVC 3. Commented Mar 9, 2011 at 21:17

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.