public static void ProcessRequest(HttpContext context, ElmahCore.ErrorLog errorLog) { var response = context.Response; response.ContentType = "application/xml"; // // Retrieve the ID of the requested error and read it from // the store. // var errorId = context.Request.Query["id"].FirstOrDefault(); if (string.IsNullOrEmpty(errorId)) { throw new ApplicationException("Missing error identifier specification."); } var entry = errorLog.GetError(errorId); // // Perhaps the error has been deleted from the store? Whatever // the reason, pretend it does not exist. // if (entry == null) { context.Response.StatusCode = 404; } // // Stream out the error as formatted XML. // var settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; settings.CheckCharacters = false; var writer = XmlWriter.Create(response.Body, settings); writer.WriteStartDocument(); writer.WriteStartElement("error"); ErrorXml.Encode(entry?.Error, writer); writer.WriteEndElement(/* error */); writer.WriteEndDocument(); writer.Flush(); }
public static void ProcessRequest(HttpContext context, ElmahCore.ErrorLog errorLog) { var response = context.Response; response.ContentType = "application/json"; // // Retrieve the ID of the requested error and read it from // the store. // var errorId = context.Request.Query["id"].FirstOrDefault(); if (string.IsNullOrEmpty(errorId)) { throw new ApplicationException("Missing error identifier specification."); } var entry = errorLog.GetError(errorId); // // Perhaps the error has been deleted from the store? Whatever // the reason, pretend it does not exist. // if (entry == null) { context.Response.StatusCode = 404; } // // Stream out the error as formatted JSON. // using (var sw = new StreamWriter(response.Body)) ErrorJson.Encode(entry?.Error, sw); }