Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow file middlewares to run if there's an endpoint with a null request delegate #42458

Merged
merged 6 commits into from
Jun 28, 2022

Conversation

DamianEdwards
Copy link
Member

@DamianEdwards DamianEdwards commented Jun 27, 2022

This updates the DefaultFilesMiddleware, DirectoryBrowserMiddleware, and StaticFileMiddleware to not no-op (fall through to the next middleware in the pipeline) if they detect the request has an active endpoint with a null request delegate.

This allows the middleware to run in cases where there's an endpoint with a null RequestDelegate. This enables the ability to have an active endpoint for the purposes of communicating metadata to middleware while allowing middleware like the StaticFileMiddleware to keep performing its function, e.g. have a "dummy" endpoint to carry IAuthorizeData metadata so that the AuthorizationMiddleware performs authorization on a request before the StaticFileMiddleware runs (example here).

Fixes #42413

@DamianEdwards DamianEdwards marked this pull request as ready for review June 27, 2022 23:32
@DamianEdwards DamianEdwards modified the milestones: preview.7, 7.0-preview7 Jun 27, 2022
@DamianEdwards DamianEdwards requested a review from davidfowl June 27, 2022 23:33
Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DamianEdwards DamianEdwards merged commit a0513ea into main Jun 28, 2022
@DamianEdwards DamianEdwards deleted the damianedwards-42413-staticfiles branch June 28, 2022 02:20
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
Projects
None yet
3 participants