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

Add Middleware ordering section to Middleware doc #2516

Closed
guardrex opened this issue Jan 13, 2017 · 1 comment
Closed

Add Middleware ordering section to Middleware doc #2516

guardrex opened this issue Jan 13, 2017 · 1 comment

Comments

@guardrex
Copy link
Collaborator

guardrex commented Jan 13, 2017

Per @JunTaoLuo in #2505 (comment)

The Middleware doc should address middleware ordering that can circumvent middleware from running if it's placed after a terminal middleware.

Proposal: Add a section after the Built-in middleware section with content something like this ...

Middleware ordering

Terminal middleware, which processes a request and returns a response, placed before another middleware will prevent the downstream middleware from executing. For example, if you place the Static File Middleware before the Response Compression Middleware, your static files cannot be compressed. The Static File Middleware will fully handle requests for static files, returning them to clients before the Response Compression Middleware can execute.

public void Configure(IApplicationBuilder app)
{
    app.UseStaticFiles();
    app.UseResponseCompression();
    app.UseMvcWithDefaultRoute();
}

If you intend to use the Response Compression Middleware to compress your static files, position the Response Compression Middleware earlier in the request processing pipeline. The following example demonstrates the middleware arrangement that would result in compression of your static files.

public void Configure(IApplicationBuilder app)
{
    app.UseResponseCompression();
    app.UseStaticFiles();
    app.UseMvcWithDefaultRoute();
}
@Rick-Anderson
Copy link
Contributor

@guardrex looks good to me. Can you PR and ask [@]JunTaoLuo to review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants