I like the people to help me regarding that the username and password details are present in the table TUser .My task is how can i check the when i login using username:admin and password:admin and press login button it searches with database and then i can login inside using Nhibernate.Please help me .this is the code below
ISession session = NHibernateHttpModule.CurrentSession;
protected void rdlogin_Click1(object sender, EventArgs e)
{
TUsers users = session.CreateCriteria(typeof(TUsers))
.Add(Expression.Eq(txtusername.text, "UserID"))
.Add(Expression.Eq(txtpassword.text, "Password"))
.UniqueResult<TUsers>();
if (users != null)
{
Response.Redirect("Default.aspx");
}
else
{
Label1.Visible=true;
Label1.Text = "Invalid user name and passwprd";
}
}
You need to change a few things:
You need to trim your TextBox text fields.
TUsers users = session.CreateCriteria(typeof(TUsers))
.Add(Expression.Eq("UserID",txtusername.text.Trim()))
.Add(Expression.Eq("Password",txtpassword.text.Trim()))
.UniqueResult<TUsers>();