I'm writing a modest transaction processor with an HTTP interface. The client posts the transaction details in the body of the POST.
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.
So I put a Response.End there at the bottom. This 'works' however it does throw an exception which I simply catch and suppress.
Should I be concerned about this from either a performance or quality standpoint?
Is there any way to accomplish this more cleanly?
private void OnBeginRequest(object sender, EventArgs e) { HttpContext ctx = HttpContext.Current; try { if (ctx.Request.RequestType == "POST" && 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 { } }