Skip to content

[Analyzer] Detect middleware in pipeline after terminal middleware #44244

@JamesNK

Description

@JamesNK

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Some middleware is terminal. That means it doesn't call the next middleware (if present) and starts the request returning back down the pipeline. For example, UseSpa is terminal.

Developers could place middleware after UseSpa, not realizing it isn't executed. For example, UseEndpoints after UseSpa.

This problem also happens with WebApplication, which implicitly adds UseEndpoints to the end of the pipeline. Any terminal middleware prevents endpoints from being executed.

Describe the solution you'd like

  • Detect middleware after terminal middleware and warn the developer.
  • (maybe) Detect terminal middleware with WebApplication. Warn the developer they may need to add UseEndpoints before terminal middleware.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIndicates an issue which is related to analyzer experiencearea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions