Skip to content

404 Not Found Requests Are Not Captured By Middleware #53

@georgidhristov

Description

@georgidhristov

Description

DebugProbeMiddleware currently skips requests when context.GetEndpoint() returns null.

As a result, legitimate 404 requests are not captured or displayed in DebugProbe.

Because ASP.NET Core does not resolve endpoints for missing routes, unmatched requests bypass DebugProbe storage entirely.

Expected Behavior

404 requests should still be captured and visible in the DebugProbe UI.

This is important because:

  • debugging missing routes is a common scenario
  • developers often need visibility into invalid requests
  • monitoring unexpected traffic is useful
  • APIs frequently receive malformed or outdated routes

Suggested Fix

Remove the early return based on GetEndpoint():

var endpoint = context.GetEndpoint();

if (endpoint is null)
{
    await _next(context);
    return;
}

The middleware should continue processing requests even when no endpoint is matched.

Result

After removing this condition:

  • 404 requests are correctly captured
  • middleware behavior becomes more consistent
  • DebugProbe provides better real-world diagnostics

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions