DataSet Validation vs. ASP.NET Forms Validation
A general question on where to put validation. I have an ASP.NET form that gets/sets data from/to a DataSet. Currently, the fields in the form are validated by the form itself (e.g. for invalid length, range, etc.). Is it a good... or better idea to transfer this validation checks into the DataSet. The downside is I need to trigger update calls to the DataSet in order to get the column with errors. In using forms, I can catch the error earlier.
The main reason I'd prefer to do this is I开发者_如何学编程'd be using this Dataset assembly into another project (a WFC service?). And I'd like to re-use the same validation code when possible. If you found anything similar to what I prefer to do, please give a link. Thanks!
Validations need to happen at page level (i.e, using javascript) and also at database level. Put in in your database APIs (i.e, using stored procedures). Don't rely solely on front-end validation, and don't commit any data without validation.
You can perform additional checks at Business layer level if need be.
Use both ) DataSet validation is more reliable, but ASP.NET Forms Validation works faster, user don't have to wait server response with validation results. But form validation is easy to cheat, you could create Response mannualy and send it to server without any form validation.
精彩评论