title: How can I cleanly terminate HTTP Transaction in OnBeginRequest?
body: <p>I'm writing a modest transaction processor with an HTTP interface. The client posts  the transaction details in the body of the POST.</p>
  
  <p>All I really need is the OnBeginRequest handler. By the time I get to the bottom of this event, I'm done. No need to continue with the IIS pipeline processing on the server.</p>
  
  <p>So I put a Response.End there at the bottom. This 'works' however it does throw an exception which I simply catch and suppress.</p>
  
  <ol>
  <li><p>Should I be concerned about this from either a performance or quality standpoint?</p></li>
  <li><p>Is there any way to accomplish this more cleanly?</p>
  
  <pre><code>private void OnBeginRequest(object sender, EventArgs e)
  {
      HttpContext ctx = HttpContext.Current;
  
      try
      {
          if (ctx.Request.RequestType == "POST" &amp;&amp; ctx.Request.IsSecureConnection)
          {
              // Here's where processing is implemented...
  
             ctx.Response.StatusCode = 200;
             ctx.Response.Write("OK");
          }
          else
          {
             ctx.Response.StatusCode = 403;
             ctx.Response.Write("BAD");
          }
      }
      catch (Exception ex)
      {
          ctx.Response.StatusCode = 500;
          ctx.Response.Write("ERROR");
      }
  
      try
      {
          ctx.Response.End();
      }
      catch { }
  }
  </code></pre></li>
  </ol>