Hello......
I have a login project and it is running successfully but after login it is not saving the login session and because of this, i am unable to access the secure page. How to save the login session, please help me. Here is coding which i am using for the same...
//this is the code behind the login button click event
protected void log_Click(object sender, EventArgs e)
{
SqlDataSource sds = new SqlDataSource();
sds.ConnectionString = ConfigurationManager.ConnectionStrings["myDbConnectionString1"].ToString();
sds.SelectParameters.Add("username", TypeCode.String, this.username.Text);
sds.SelectParameters.Add("password", TypeCode.String, this.password.Text);
sds.SelectCommand = "SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password";
DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);
if (dv.Count == 0)
{
this.lblinfo.ForeColor = System.Drawing.Color.Red;
this.lblinfo.Text = "Invalid username and password!";
return;
}
else
{
// Creating session for user
this.Session["username"] = dv.Row["username"].ToString();
this.Session["password"] = dv.Row["password"].ToString();
Response.Redirect("securepage/SecurePage.aspx");
}
}
What I have to use instead of red colored texts to work.
Help me !
Loading

Daniel VarghesePosted Jul 2, 2010, 3:28 PM
I presume that your code is setting the values in the Session on the login page, but is not persisted on the Next Page ie SecurePage.aspx
Can you please check if you have the following line in your web.config file