April 2013 Entries

MVC Model State Validation–DRY to the rescue!
ASP.NET MVC comes with nice features to aid model validation. Unfortunately, you are still stuck writing boilerplate code on all the data entry actions. The boilerplate code looks something like: public ActionResult DoSomething(Foo value){ if (ModelState.IsValid) { return View(); } ...// do actual work return View("AllGoodThanks");} The common desired behavior is that when the submitted model is invalid the view is immediately returned so the user can fix erroneous entries. But since the flow is ......

Posted On Thursday, April 11, 2013 4:49 AM | Comments (2)