---
title: Debug request handler invocation
summary: Logs every request at Debug level with request details.
status: draft
owner: Framework.NCore maintainers
last_reviewed: 2026-10-02
library: SAIF.NetCore.ServiceExtensions
reference_type: package
operation_id: OP-12
trigger: Any HTTP request passes through a pipeline where ConfigureDebugRequestHandling() was applied.
---

# Debug request handler invocation

This operation is request-pipeline middleware that logs a Debug-level entry describing every incoming request before passing control to the rest of the pipeline.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-12 |
| **Trigger** | Any request through a pipeline configured with `ConfigureDebugRequestHandling()`. |
| **Inputs** | The `HttpContext` for the current request. |
| **Outputs** | A Debug-level log entry; control passed to the next middleware. |
| **Primary components** | `DebugRequestHandler.InvokeAsync` |
| **Entry point** | `src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/Middleware/DebugRequestHandler.cs` (L36–46) |

## Steps

1. Build a message from `IEnvironmentClient.ApplicationName`, `ApplicationHost`, `Environment.MachineName`, `TrackName`, and `HttpContextToLogMessage(context)` (`new WebRequestDetails()` → `Initialize(context)` → `ToString()`) ([BR-SE-15](../business-rules.md#br-se-15-every-request-is-logged-at-debug-level))

   > **Origin**: `ApplicationName`/`ApplicationHost`/`TrackName` resolution is implemented in [`Get setting value`](../../saif-netcore-environmentclient/operations/get-setting-value.md) (`SAIF.NetCore.EnvironmentClient`) and executed on behalf of this operation.
2. `ISaifLogService.Debug(message)` writes the built message at Debug level ([BR-SE-15](../business-rules.md#br-se-15-every-request-is-logged-at-debug-level))

   > **Origin**: Debug-level log emission is implemented in [`Emit information log entry`](../../saif-netcore-logging/operations/op-05-emit-information-log-entry.md) (`SAIF.NetCore.Logging`) and executed on behalf of this operation.
3. `await next(context)` passes control to the rest of the pipeline.

## Process flow

This diagram shows the per-request path through this middleware only — from request entry to `await next(context)` — not the surrounding pipeline stages documented in other operations.

```mermaid
flowchart TD
    Start([Request enters pipeline]) --> S1[Build request-details log message]
    S1 --> S2[ISaifLogService.Debug]
    S2 --> S3[await next]
    S3 --> EndOk([Request continues down the pipeline])
```

## Failure and edge-case behavior
- This middleware does not catch exceptions; any failure in logging or in the downstream pipeline propagates to [Dynamic error handler invocation](dynamic-error-handler-invoke.md) when both are configured (Debug request handling runs after error handling in the pipeline, per [App startup configure pipeline](app-startup-configure-pipeline.md)).

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/Middleware/DebugRequestHandler.cs`
