Here is my code
1 da.SelectCommand.CommandText = "select * from users where UserName='" + username.Text + "' and Password='" +password.Text+"'";
2
3 try
4 {
5 da.Fill(ds);
6
7 }
8 catch
9 {
10 Response.Write("<script language='javascript'>alert('Database maintainance is ongoing please try again later.');</script>");
11 }
12
13 try
14 {
15
16 if (ds.Tables[0].Rows.Count > 0)
17 {
18 Session["User"] = username.Text;
19 Session["Role"] = ds.Tables[0].Rows[0]["Role"].ToString();
20
21 Response.Redirect("list.aspx");
22
23 }
24 else
25 {
26 Response.Write("<script language='javascript'>alert('Invalid Username or Password');</script>");
27 }
28
29 }
30 catch (Exception ex)
31 {
32 Response.Write("<script language='javascript'>alert('" + ex.Message + "');</script>");
33 }
when it comes to Response.Redirect("list.aspx"); it throws exception "base {System.Exception} = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}"
but it gets transfered properly