title: How to Set TimeoutException in C# and redirec to CustomErrorPage.aspx
body: <p>I am trying to set the TimeoutException for command and on which if " Command TimeoutException" occurs in code it must go to catch block and further redirect to customerror.aspx page.
  Code is:</p>
  
  <pre><code>try
  {
     command.Timeout=1; //which is in seconds for testing i have set it to one.
     //some code here
     // if TimeoutException occurs, it must go to following block which doesnthappen
     //And  it goes to catch 2: block..! Why is it so...?
  }
  
  //catch 1:
  catch (TimeoutException ex)
  {
       Response.Redirect("CustomError.aspx");
  
  }
  
  //catch 2:
  catch (Exception ex)
  {
       Response.Redirect("CustomError.aspx");
  }
  </code></pre>