Response.Redirect unknown exception

Last post 10-07-2008 5:02 AM by pavankumarkavety. 2 replies.

Sort Posts:

  • Response.Redirect unknown exception

    10-07-2008, 3:24 AM

    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("&lt;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("&lt;script language='javascript'>alert('Invalid Username or Password');</script>");
    27                   }
    28            
    29           }
    30           catch (Exception ex)
    31           {
    32               Response.Write("&lt;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
  • Re: Response.Redirect unknown exception

    10-07-2008, 3:59 AM
    Answer
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    This is a well known issue, You should add the second parameter of the Response.Redirect method

    Response.Redirect("list.aspx",false);

     

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: Response.Redirect unknown exception

    10-07-2008, 5:02 AM
    • Participant
      1,206 point Participant
    • pavankumarkavety
    • Member since 02-20-2008, 7:32 AM
    • banagalore
    • Posts 447

    inorder not to stop the execution of the current thread u need to keep it as false.

    pavankumar
Page 1 of 1 (3 items)
Microsoft Communities