I am trying to have an error message displayed when a username and password are not recognized.
if (rdr.Read())
{
int id = int.Parse(rdr.GetValue(0).ToString());
string fname = rdr.GetString(1);
Session["ID"] = id;
Session["FName"] = fname;
con.Close();
Response.Redirect("Home.aspx");
}
else
{
Response.Redirect("Login.aspx?err='blabla'"); //Display message
}
The following code (Page_Load) is supposed to be invoked in the else statement, but it is not:
public partial class _Default : System.Web.UI.Page
{
protected string err = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form.Count > 0)
{
err = Request.Form["err"];
}
}
}
Why is this the case? Thank you all so much!