Context.Response.End() and Thread was being aborted
<p>I am trying to close the response using <code>Context.Response.End</code> but receive error <code>"Thread was being aborted"</code>. </p>

<p>How do I correctly close the response without triggering an exception?</p>

<pre><code>try {
   Context.Response.Clear();
   Context.Response.ContentType = "text/html"; 
   //Context.Response.ContentType = "application/json";
   JsonObjectCollection collection = new JsonObjectCollection();
   collection.Add(new JsonNumericValue("resultcode", 1));
   collection.Add(new JsonStringValue("sourceurl", exchangeData.cUrl));
   collection.Add(new JsonStringValue("filename", fileName));
   collection.Add(new JsonStringValue("filesize", fileSize));
   collection.Add(new JsonStringValue("fileurl", Common.GetPDFURL + outputFileName));
   JsonUtility.GenerateIndentedJsonText = true;
   Context.Response.Write(collection);
  try {
     Context.Response.End();
  } catch (ThreadAbortException exc) {
     // This should be first catch block i.e. before generic Exception
     // This Catch block is to absorb exception thrown by Response.End
  }
} catch (Exception err) {

}
</code></pre>

<p>Solved by myself, the code should look like</p>

<pre><code>try {
  Context.Response.End();
} catch (ThreadAbortException err) {

}
catch (Exception err) {
}
</code></pre>
