ASP.NET MVC ModelState should work like TempData

I prefer to have the actions that forms post to just process the posted data and then redirect to a different action for viewing the results. So in order to pass validation errors back to the form action I need ModelState to work like TempData does. In fact it seemed that before ModelState was added that one of the most common scenarios for using TempData was passing validation error messages between actions so I’m not sure why it doesn't already work like this. I’m using RC2 so its doubtful this will change before RTM. :(

Anyhoo, this code totally saved me: http://www.jeremyskinner.co.uk/2008/10/18/storing-modelstate-in-tempdata-with-aspnet-mvc/

No Comments