Middleware that tracks exceptions in Application Insights telemetry and returns a generic error response.
Remarks: This middleware captures unhandled exceptions from the pipeline, tracks them in Application Insights, and returns an HTTP 500 status with a user-friendly error message including the correlation ID.
public class ExceptionTelemetryMiddleware
Task InvokeAsync(HttpContext context)Summary: Invokes the middleware to process the HTTP request and track exceptions.
Parameters:
context- The HTTP context.Returns: A task representing the asynchronous operation.
Middleware that handles Azure App Service keep-alive pings to prevent false-negative health check reports.
Remarks: This middleware intercepts GET requests to the root path (/) and returns HTTP 200 OK immediately. This prevents Application Insights from reporting failed requests when Azure App Service performs keep-alive pings over HTTP instead of HTTPS.
public class KeepAliveMiddleware
Task InvokeAsync(HttpContext context)Summary: Invokes the middleware to process the HTTP request.
Parameters:
context- The HTTP context.Returns: A task representing the asynchronous operation.
Middleware that ensures correlation and request IDs are present in both request and response headers.
Remarks: This middleware manages the x-correlation-id and x-request-id headers, generating new GUIDs if not provided. These headers are essential for distributed tracing and request tracking across microservices.
public class RequestCorrelationMiddleware
Task InvokeAsync(HttpContext context)Summary: Invokes the middleware to ensure correlation headers are set.
Parameters:
context- The HTTP context.Returns: A task representing the asynchronous operation.
Middleware that logs HTTP request and response details for debugging and monitoring purposes.
Remarks: This middleware captures request and response information including headers, query parameters, and body content. It supports configurable logging options through
Atc.Rest.Options.RequestResponseLoggerOptions, such as: Skipping Swagger and SignalR requestsIncluding/excluding query parameters, headers, and response bodyAutomatic redaction of binary contentException tracking Binary content is replaced with "# BINARY-DATA-REDACTED #" to prevent large log entries.
public class RequestResponseLoggerMiddleware
Task InvokeAsync(HttpContext httpContext)Summary: Invokes the middleware to log request and response details.
Parameters:
httpContext- The HTTP context.Returns: A task representing the asynchronous operation.