Consideration validation email in Data Base
I need to store in a Table messages which are sent using a classical web page CONTACT US.
My question is: Would be better doing email validation on Business layer or better at Data Base level?
Regarding email validation in BL I would like to know if using asp.net 4 there is some sort of automatic system for validating emails instead of complicated regex or similar.
Regarding validation in DataBase I found out this article, seems quite useful.
http://vyaskn.tripod.com/handling_email_addresses_in_sql_se开发者_如何学运维rver.htm
I would appreciate your opinions.
Thanks for your support :-)
I would handle the validation at the business layer. I try to keep as much logic out of the database as possible.
Also, I don't worry about getting the perfect regex for email addresses. I usually just check that it contains an @ character. I don't want my validation to disallow some valid email address that I didn't think of. If I want to be sure that it's a good address, I'll send an email to it, and ask them to click a link to validate their email address.
I think what you want from asp.net is available http://www.beansoftware.com/ASP.NET-Tutorials/Validation-In-ASP.NET.aspx
As for the validation, I would do it at the business level so you can easily go back and get the user to correct their error. Doing it at the database level would mean going back up two levels to get a correction. Basically, validate as soon as possible to minimise problems.
精彩评论