title: How to avoid "Response.Redirect cannot be called in a Page callback"
body: <p>I'm cleaning up some legacy framework code and a huge amount of it is simply coding by exception.  No values are checked to see if they are null, and as a result, copious amounts of exceptions are thrown and caught. </p>
  
  <p>I've got most of them cleaned up, however, There are a few error / login / security related framework methods that are doing Response.Redirect and now that we are using ajax, we are getting ALOT of <strong>"Response.Redirect cannot be called in a Page callback."</strong>  And I'd like to avoid this if at all possible.</p>
  
  <p>Is there a way to programatically avoid this exception?  I'm looking for something like</p>
  
  <pre><code>if (Request.CanRedirect)
      Request.Redirect("url");
  </code></pre>
  
  <p>Note, this is also happening with Server.Transfer, so I'd like to be able to check if I am able to do Request.Redirect OR Server.Transfer.</p>
  
  <p>Currently, its simply doing this</p>
  
  <pre><code>try
  {
      Server.Transfer("~/Error.aspx"); // sometimes response.redirect
  }
  catch (Exception abc)
  {
      // handle error here, the error is typically:
      //    Response.Redirect cannot be called in a Page callback
  }
  </code></pre>