title: Getting Thread Abort Exception while using Response.Redirect()
body: <p>I wrote the following piece of code in a page which is under Update Panel.</p>
  
  <pre><code>protected void myGrid_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      try
      {
          if (e.CommandName =="EditNames")
          {
              long lSelectedName = Convert.ToInt64(e.CommandArgument);
              Session["SelectedItem"] = lSelectedName;
              Response.Redirect("EditItem.aspx");
          }
          else if (e.CommandName =="DeleteNames")
          {
              long lSelectedName = Convert.ToInt64(e.CommandArgument);
              ValidName.DeleteItem(lSelectedName);
  
              ScriptManager.RegisterStartupScript(this, GetType(), "Key", "alert('Name deleted sucessfully')", true);
          }
      }
      catch (System.Threading.ThreadAbortException)
      {
  
      }
      catch (Exception ex)
      {
          Error handling code...
      }
  }
  </code></pre>
  
  <p>Here, I am getting a Thread Abort Exception while redirecting. However, I resolved it by using an error handler <code>System.Threading.ThreadAbortException</code>.</p>
  
  <p>But I am unsure why that error came while redirecting. Even though I solved this problem, I would like to know is there any mistake in the way I am coding or is there any way to stop the error firing at all.</p>
  
  <p>Give your inputs...</p>
  
  <p>Note that the page is under AJAX UPDATE PANEL.</p>