I don't know what the problem is, its the first time using the login control and
I'm using a custom approach of authentication. When I try to log in, it won't even
get into the debugger. I'm using Vista Premium, Visual Studio 2005, SQL Server
and ASP.NET 2.0
My Code Look Like this:
protected void DefaultLogin_Authenticate(object sender, AuthenticateEventArgs e)
{
bool isAuthenticated = false;
isAuthenticated = SiteLevelCustomAuthentication(DefaultLogin.UserName, DefaultLogin.Password);
e.Authenticated = isAuthenticated;
if (isAuthenticated == true)
{
Response.Redirect("WelcomePage.aspx");
}
}
public bool SiteLevelCustomAuthentication(String username, String password)
{
bool isAuthenticated = false;
strConnection =
ConfigurationManager.ConnectionStrings["DB1"].ConnectionString;sqlConn = new SqlConnection(strConnection);
cmd =
new SqlCommand("spGetAuthenticationStatus", sqlConn);cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(
new SqlParameter(@username, SqlDbType.VarChar)).Value = username;cmd.Parameters.Add(new SqlParameter(@password, SqlDbType.VarChar)).Value = password;
try
{
sqlConn.Open();
int ret = cmd.ExecuteNonQuery();if (ret == -1)
{
isAuthenticated = false;
}
else
{
isAuthenticated =
true;}
}
catch (SqlException)
{
}
finally
{
sqlConn.Close();
}
return isAuthenticated;
}
Thanks in Advance,
Programor