title: HttpResponse.End vs HttpResponse.Close vs HttpResponse.SuppressContent
body: <p>Within an ASPX page, I want to end the response at specific points (not due to an error condition), depending on code path, so that nothing else is sent back down the stream.
  So naturally used:</p>
  
  <pre><code>Response.End();
  </code></pre>
  
  <p>This results in a ThreadAbortException, which is <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end%28VS.80%29.aspx" rel="noreferrer">by design</a>.</p>
  
  <p>The following seems to work but does not look like the correct approach as per <a href="https://stackoverflow.com/questions/736301/asp-net-how-to-stream-file-to-user">this SO question</a>:</p>
  
  <pre><code>Response.Flush();
  Response.Close();
  </code></pre>
  
  <p>So, how about this?</p>
  
  <pre><code>Response.Flush();
  Response.SuppressContent = true
  </code></pre>
  
  <p>and then just let the page complete normally.</p>
  
  <p>I could just handle and swallow the ThreadAbortException, but I just want to find out if there is anything wrong/gotchas with the SuppressContent approach?</p>
  
  <p><strong>Edit:</strong>
  To give a bit more of an example. Say I have a ASPX page whereby I may change the content-type to one of a number of possibilities. Depending on the content-type and scenario, at a given point in the code I want to prevent any more content from being sent to the client. Assume after SuppressContent has been set set to true, that there is no issue with any further server-side code running. I just don't want anything else to be sent to the client.</p>
  
  <p><strong>Edit 2:</strong>
  MyPage.aspx - has a master page which may include standard content, headers, footers etc etc. This page can just render as a normal page. It also can just write out an (e.g.) XML document to be downloaded. If writing out an XML document (determined on page load), it will clear the ouput, set the content-type to XML, write all the XML out and then if left normally, you end up with the rest of the ASPX page rendering being tacked on to the end - that is obviously not required/breaks the XML. </p>
  
  <p><strong>Edit 3:</strong>
  For now I'm using the SuppressContent approach. 
  To try and draw this question to a close, I'm raising a bounty and will put the question another way: When <em>should</em> you use SuppressContent? Why would you use it instead of Response.End?</p>
  
  <hr>
  
  <p><strong>Please see the answer I provided below for the solution I actually ended up with as I eventually found a way to avoid the ThreadAbortException when using Response.End. I had already excepted an answer by this point.</strong></p>
  
  <hr>