Validation in a three tier architecture

S

Student

Good evening,

I create a three tier ASP.NET web application. How can I validate the
form input data in the Business Logic Layer? Can anyone give me an
example?
 
M

Michael Nemtsev

Hello Student,

Why not to use ASP.net validators for this?

S> Good evening,
S> I create a three tier ASP.NET web application. How can I validate the
S> form input data in the Business Logic Layer? Can anyone give me an
S> example?
S>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
J

John Bailo

Student said:
Good evening,

I create a three tier ASP.NET web application. How can I validate the
form input data in the Business Logic Layer? Can anyone give me an
example?

Well, what I do, is in the submit method, you could take the values of
your form, and run them through your validation methods. If the
validation returns false, then don't do a Server.Transfer to the next
page, put the user back on form where the problem is


private void bookingSubmit_Click(object sender, System.EventArgs e)

{

if(this.validateForm())
{
//data is ok; proceed
Server.Transfer("nextpage.aspx");
}


}

//this method could be in the "business logic layer"
bool validateForm()
{
if(this.FirstName.Length==0)
return false;

//... and so on
}
 
G

Guest

Validation is one area where you cannot do all validation in one place.
Sometimes you need to validate on the page, sometimes in the server
code, in the business object and again in the data services area. I try
and at least have all validation done in the business object so there
is one place where the validation rules exist but you will have to
duplicate validation in other areas too. For example you may check that
you got a particular value. You may wish to check this on the page so
the user gets immediate response but by the time it hits the business
object you want to validate it again because you may be unsure where
the data came from (and hence has it been validated) and also people
can post to your website without going through your pages so if it
assumes something has been already checked you may open yourself up for
attacks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top