I just wanted to do a “refresher” post regarding ASP.NET MVC validation as many things have changed over the last couple of months and there is a lot of information out there. I wanted to aggregate my known validation options and recommend them in one tabular list. Whilst I’m scared to write “best practice” now a days, I do believe that the below list is really worthwhile, and are the most prominent and reputable on the net, and one in particular, the xVal framework I am using in a real-world project with absolutely no hassles and no apparant drawbacks. However, I write that disclaimer as there is always something else out there
. So without further ado, Ill get to the list, which is hopefully simple and easy to follow.
I hope this list can help alleviate any confusion amongst anyone not sure on the best path to go down, or at least provide a good starting point for those of you new to ASP.NET MVC and a validation strategy.
Technique/tool Author Release date Server-side support
(validation performed by .NET out-of-the-box)Client-side support
(validation performed by JavaScript out-of-the-box)Client “ajax” server-side support
(validation performed by JavaScript AJAX call to server-side .NET validation out-of-the-box)ORM-targeted Rating xVal Framework (tutorial here / L2S? See below.) Steve Sanderson Jan 10 2009 *
devermind.com: Client-side form validation made easy (w/ xVal) Adrian Grigore Jun 21 2009 Validator Toolkit for ASP.NET MVC (haven’t tried it!) Jürgen Bäurle Jan 29 2008 ? ? ??? Error Handling with built-in ModelState object Microsoft Framework release Error handling with built-in IDataErrorInfo Interface Microsoft Framework release Error handling with built-in Data Annotation Model Binding Interface Microsoft Framework release
WHAT I RECOMMEND:
xVal + if you need client-side “ajax” validation calls, Adrian Grigores’ RemotePropertyValidator API which snaps right on to xVal.
* IF YOU CHOOSE XVAL (GREAT!):
Are you using LINQ to SQL and wish to declare your validation rules via .NET Data Annotations attributes? If so, click here.
(This outlines how to get this working so L2S re-generation doesn’t interfere with your property attributes for your model.)
If anyone has seen my older validation articles you’ll notice I had an Emad Ibrahim “validation hybrid”, but since xVal came along this is my framework of choice and also Emad’s didn’t support Linq to Sql.
If you have any others, comment and I’ll post them for others.
4 Comments
Super helpful! Thanks.
very good article
thank you very much
Check this out.
http://aspnetmvcval.codeplex.com/
Great guide, thanks a heap man.
One Trackback/Pingback
[...] techniques here Possibly related posts: (automatically [...]
Post a Comment