protected void Application_EndRequest()
{
// Handling error conditions...
// Inspiration: http://stackoverflow.com/a/9026907
var code = Context.Response.StatusCode;
// Add more conditions here as you need them
if (code == 404) { this.HandleError("NotFound"); }
//if (code >= 500) { this.HandleError("ServerError"); }
}