-----Original Message-----
hello,
i am trying to write aspx login system and the login process requires avalidity check of username and password.
i have a c# class which calls the database and checks if the username andpassword is valid, but if an incorrect username or password is entered iwant to raise an error to the aspx so i can display the error message. (ihope this is the best way!).
my code that raises the error is the username/password is invalid is:
throw new Exception("The username/password is invalid.");
my problem is that when i run/debug my code this line makes the aspx stoprunning and the error is displayed as a system error on the aspx page. howcan i pass the error message back to my aspx page so i can display it?
thanks
..
As Rob said this is a very expensive approach to user
valdiation. A less expensive approach would be to use a
stored procedure on the server that you pass a user name
and password to. It then returns a value (maybe just a
boolean) indicating if the login failed or not.
So you could use something like the following:
private bool UserLogin(string strUserName, string
strPassword)
{
//Code to execute stored proc and return boolean
}
//////////////////
//Check user login
if(UserLogin("Tom","Secret"))
{
//Good login
}
else
{
//login failed
}
Hope this helps,
Lee