Hello, I have two webforms one is login page and another is home page. Whenever i clicks on logout button in "home page" it redirects to "login page" and if i clicks on "back" button in browser it redirects to home page which shouldn't be happened. Now my query is that whenever i would click "back" button in browser(after logging out from home page)it would redirect to login page rather than home page. Thanks........
LogIn Page Code:
try
{
Session["ename"] = TextBox1.Text;
cn.Open();
SqlCommand SqlCmd = new SqlCommand("SELECT * FROM empregd WHERE ename='" + TextBox1.Text + "' AND password='" + TextBox2.Text + "'", cn);
SqlDataAdapter SqlDa = new SqlDataAdapter(SqlCmd);
SqlDataReader SqlDr = SqlCmd.ExecuteReader();
if (SqlDr.Read())
{
Response.Redirect("http://localhost:49871/WebSite7/Default6.aspx");
}
SqlDr.Close();
cn.Close();
TextBox1.Text = "";
TextBox2.Text = "";
}
catch (Exception ex)
{
throw ex;
}
HomePage Code
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["ename"]== null)
{
Response.Redirect("http://localhost:49871/WebSite7/Default5.aspx");
}
Label2.Text = Session["ename"].ToString();
}
catch (Exception ex)
{
throw ex;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("http://localhost:49871/WebSite7/Default5.aspx");
FormsAuthentication.SignOut();
Session.Abandon();
Session.Clear();
Session["ename"] = null;
}
catch (Exception ex)
{
throw ex;
}
}