-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Registration flag for all middleware #66211
Copy link
Copy link
Open
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionfeature-authentication
Metadata
Metadata
Assignees
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionfeature-authentication
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Add a registration flag for all middleware to indicate whether it has already been added to the pipeline, similar to
UseAuthenticationandUseAuthorization. Currently,UseSessionand some other middleware do not expose such a flag, making it hard to prevent duplicate registrations.Motivation and goals
UseAuthenticationandUseAuthorizationalready implement this pattern with internal flags, butUseSessiondoes not. Adding this would unify middleware behavior across the framework.Goals:
UseSession,UseCors,UseResponseCachingcan optionally adopt this.In scope
SessionMiddlewareand its extension methods. (UseCors,UseResponseCaching...)Out of scope
Risks / unknowns
UseSession()to be idempotent already; adding the flag could change subtle behaviors if a middleware was previously registered twice intentionally.UseSessionmultiple times should not break.Examples