I've received a lot of email about the best way to handle validation in an ASP.NET MVC application. We posted three new tutorials on validation at the http://www.ASP.net/mvc website. Here is the list:
- Performing Simple Validation - Learn how to perform validation in an ASP.NET MVC application. In this tutorial, Stephen Walther introduces you to model state and the validation HTML helpers.
- Validating with the IDataErrorInfo Interface - Stephen Walther shows you how to display custom validation error messages by implementing the IDataErrorInfo interface in a model class.
- Validating with a Service Layer - Learn how to move your validation logic out of your controller actions and into a separate service layer. In this tutorial, Stephen Walther explains how you can maintain a sharp separation of concerns by isolating your service layer from your controller layer.
I don't want to suggest that these are the only methods of performing validation in an ASP.NET MVC application. For example, an alternative that is not discussed in these tutorials is the Microsoft Enterprise Library Validation Application Block. In future tutorials, I'll discuss other methods of performing validation.
Here's the direct link to the MVC Validation tutorial category:
ASP.NET MVC Validation