Modern way to validate POST-data in MVC 2

Posted by zerkms on Stack Overflow See other posts from Stack Overflow or by zerkms
Published on 2010-05-04T23:20:46Z Indexed on 2010/05/04 23:28 UTC
Read the original article Hit count: 178

There are a lot of articles devoted to working with data in MVC, and nothing about MVC 2.

So my question is: what is the proper way to handle POST-query and validate it.

Assume we have 2 actions. Both of them operates over the same entity, but each action has it's own separated set of object properties that should be bound in automatic manner. For example:

  • Action "A" should bind only "Name" property of object, taken from POST-request
  • Action "B" should bind only "Date" property of object, taken from POST-request

As far as I understand - we cannot use Bind attribute in this case.

So - what are the best practices in MVC2 to handle POST-data and probably validate it.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-2