0

I am developing in ASP.NET MVC with EF 4.1 with Data Annotations. The client side validation is working as expected. But I have this doubt. For example when a required field (example: product name) , goes null from the client to server and if the entity model is throwing exception. How can I handle this case?

Some additional info is that, I consume the EF via WCF service layer

1 Answer 1

1

You should be validating the model on the server side/controller too by calling model.isvalid, for more info on MVC server side validation:

http://msdn.microsoft.com/en-us/library/dd410404(v=vs.90).aspx

Hope that helps.

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

3 Comments

That looks great. I thought of firing the Data Annotation validations by default without doing this manual validations
You could implement a custom action filter, which calls the isvalid on the model before, there's a nice little blog on it here: ben.onfabrik.com/posts/…
Just be cautious doing it this way as it might add some confusion.

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.