From e5a04108e8b98cca4212250aea66f641f7517c6c Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Wed, 4 Mar 2026 02:02:54 +0300 Subject: [PATCH] Static File Middleware -> Static Files Middleware --- aspnetcore/fundamentals/middleware/index.md | 38 ++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/aspnetcore/fundamentals/middleware/index.md b/aspnetcore/fundamentals/middleware/index.md index 7658f31e2d7c..00a35f950d7d 100644 --- a/aspnetcore/fundamentals/middleware/index.md +++ b/aspnetcore/fundamentals/middleware/index.md @@ -124,7 +124,7 @@ In the app's console window when the app is run: > :::no-loc text="Work that doesn't write to the response. (2)"::: > :::no-loc text="Work that doesn't write to the response. (1)"::: -*Short-circuiting* the request pipeline is often desirable because it avoids unnecessary work. For example, [Static File Middleware](xref:fundamentals/static-files) can act as a *terminal middleware* by processing a request for a static file and short-circuiting the rest of the pipeline. Middleware added to the pipeline before the terminal middleware still processes code after their `next.Invoke` statements. If you don't plan to call `next.Invoke` because your goal is to terminate the pipeline, use a [`Run` delegate](#run-delegate) instead of calling the extension method. +*Short-circuiting* the request pipeline is often desirable because it avoids unnecessary work. For example, [Static Files Middleware](xref:fundamentals/static-files) can act as a *terminal middleware* by processing a request for a static file and short-circuiting the rest of the pipeline. Middleware added to the pipeline before the terminal middleware still processes code after their `next.Invoke` statements. If you don't plan to call `next.Invoke` because your goal is to terminate the pipeline, use a [`Run` delegate](#run-delegate) instead of calling the extension method. Don't call `next.Invoke` during or after the response is sent to the client. After an is started, changes result in an exception. For example, [setting headers or a response status code throw an exception](xref:fundamentals/best-practices#do-not-modify-the-status-code-or-headers-after-the-response-body-has-started) after the response starts. Writing to the response body after calling `next` may: @@ -361,7 +361,7 @@ app.Use(async (context, next) => }); ``` -When a delegate doesn't pass a request to the next delegate, it's called *short-circuiting the request pipeline*. Short-circuiting is often desirable because it avoids unnecessary work. For example, [Static File Middleware](xref:fundamentals/static-files) can act as a *terminal middleware* by processing a request for a static file and short-circuiting the rest of the pipeline. Middleware added to the pipeline before the middleware that terminates further processing still processes code after their `next.Invoke` statements. However, see the following warning about attempting to write to a response that has already been sent. +When a delegate doesn't pass a request to the next delegate, it's called *short-circuiting the request pipeline*. Short-circuiting is often desirable because it avoids unnecessary work. For example, [Static Files Middleware](xref:fundamentals/static-files) can act as a *terminal middleware* by processing a request for a static file and short-circuiting the rest of the pipeline. Middleware added to the pipeline before the middleware that terminates further processing still processes code after their `next.Invoke` statements. However, see the following warning about attempting to write to a response that has already been sent. > [!WARNING] > Don't call `next.Invoke` after the response has been sent to the client. Changes to after the response has started throw an exception. For example, [setting headers and a status code throw an exception](xref:fundamentals/best-practices#do-not-modify-the-status-code-or-headers-after-the-response-body-has-started). Writing to the response body after calling `next`: @@ -555,7 +555,7 @@ The following examples demonstrate middleware order for common app scenarios. Ea * Exception Handler Middleware () catches exceptions thrown in the following middlewares. * HTTP Strict Transport Security Protocol (HSTS) Middleware () adds the `Strict-Transport-Security` header. 1. HTTPS Redirection Middleware () redirects HTTP requests to HTTPS. -1. Static File Middleware (if required, ) returns static files and short-circuits further request processing. +1. Static Files Middleware (if required, ) returns static files and short-circuits further request processing. 1. Cookie Policy Middleware () conforms the app to the EU General Data Protection Regulation (GDPR). 1. Routing Middleware () to route requests. 1. Authentication Middleware () attempts to authenticate the user before they're allowed access to secure resources. @@ -629,7 +629,7 @@ In the preceding code: * CORS Middleware (), Authentication Middleware (), and Authorization Middleware () must appear in the order shown. * CORS Middleware () must appear before Response Caching Middleware () to add CORS headers on every request, including cached responses. For more information, see [It is not clear that UseCORS must come before UseResponseCaching (`dotnet/aspnetcore` #23218](https://github.com/dotnet/aspnetcore/issues/23218). -* Request Localization Middleware () must appear before any middleware that might check the request culture, for example, Static File Middleware (). +* Request Localization Middleware () must appear before any middleware that might check the request culture, for example, Static Files Middleware (). * Rate Limiting Middleware () must be called after Routing Middleware () when rate limiting endpoint-specific APIs are used. For example, if the [`[EnableRateLimiting]` attribute](xref:Microsoft.AspNetCore.RateLimiting.EnableRateLimitingAttribute) is used, Rate Limiting Middleware must be called after Routing Middleware. When calling only global limiters, Rate Limiting Middleware can be called before Routing Middleware. In some scenarios, middleware has different ordering. For example, caching and compression ordering depends on the app's specification. In the following order, CPU usage might be reduced by caching the compressed response, but the app might end up caching multiple representations of a resource using different compression algorithms, such as Gzip or Brotli: @@ -746,7 +746,7 @@ The following `Program.cs` code adds middleware components for common app scenar * Exception Handler Middleware () catches exceptions thrown in the following middlewares. * HTTP Strict Transport Security Protocol (HSTS) Middleware () adds the `Strict-Transport-Security` header. 1. HTTPS Redirection Middleware () redirects HTTP requests to HTTPS. -1. Static File Middleware () returns static files and short-circuits further request processing. +1. Static Files Middleware () returns static files and short-circuits further request processing. 1. Cookie Policy Middleware () conforms the app to the EU General Data Protection Regulation (GDPR) regulations. 1. Routing Middleware () to route requests. 1. Authentication Middleware () attempts to authenticate the user before they're allowed access to secure resources. @@ -779,14 +779,14 @@ In the preceding example code, each middleware extension method is exposed on is the first middleware component added to the pipeline. Therefore, the Exception Handler Middleware catches any exceptions that occur in later calls. -Static File Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static File Middleware provides **no** authorization checks. Any files served by Static File Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . +Static Files Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static Files Middleware provides **no** authorization checks. Any files served by Static Files Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . -If the request isn't handled by the Static File Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. +If the request isn't handled by the Static Files Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. -The following example demonstrates a middleware order where requests for static files are handled by Static File Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. +The following example demonstrates a middleware order where requests for static files are handled by Static Files Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. ```csharp -// Static files aren't compressed by Static File Middleware. +// Static files aren't compressed by Static Files Middleware. app.UseStaticFiles(); app.UseRouting(); @@ -900,7 +900,7 @@ The following `Program.cs` code adds middleware components for common app scenar * Exception Handler Middleware () catches exceptions thrown in the following middlewares. * HTTP Strict Transport Security Protocol (HSTS) Middleware () adds the `Strict-Transport-Security` header. 1. HTTPS Redirection Middleware () redirects HTTP requests to HTTPS. -1. Static File Middleware () returns static files and short-circuits further request processing. +1. Static Files Middleware () returns static files and short-circuits further request processing. 1. Cookie Policy Middleware () conforms the app to the EU General Data Protection Regulation (GDPR) regulations. 1. Routing Middleware () to route requests. 1. Authentication Middleware () attempts to authenticate the user before they're allowed access to secure resources. @@ -933,14 +933,14 @@ In the preceding example code, each middleware extension method is exposed on is the first middleware component added to the pipeline. Therefore, the Exception Handler Middleware catches any exceptions that occur in later calls. -Static File Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static File Middleware provides **no** authorization checks. Any files served by Static File Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . +Static Files Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static Files Middleware provides **no** authorization checks. Any files served by Static Files Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . -If the request isn't handled by the Static File Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. +If the request isn't handled by the Static Files Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. -The following example demonstrates a middleware order where requests for static files are handled by Static File Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. +The following example demonstrates a middleware order where requests for static files are handled by Static Files Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. ```csharp -// Static files aren't compressed by Static File Middleware. +// Static files aren't compressed by Static Files Middleware. app.UseStaticFiles(); app.UseRouting(); @@ -1037,7 +1037,7 @@ The following `Startup.Configure` method adds middleware components for common a * Exception Handler Middleware () catches exceptions thrown in the following middlewares. * HTTP Strict Transport Security Protocol (HSTS) Middleware () adds the `Strict-Transport-Security` header. 1. HTTPS Redirection Middleware () redirects HTTP requests to HTTPS. -1. Static File Middleware () returns static files and short-circuits further request processing. +1. Static Files Middleware () returns static files and short-circuits further request processing. 1. Cookie Policy Middleware () conforms the app to the EU General Data Protection Regulation (GDPR) regulations. 1. Routing Middleware () to route requests. 1. Authentication Middleware () attempts to authenticate the user before they're allowed access to secure resources. @@ -1078,16 +1078,16 @@ In the preceding example code, each middleware extension method is exposed on is the first middleware component added to the pipeline. Therefore, the Exception Handler Middleware catches any exceptions that occur in later calls. -Static File Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static File Middleware provides **no** authorization checks. Any files served by Static File Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . +Static Files Middleware is called early in the pipeline so that it can handle requests and short-circuit without going through the remaining components. The Static Files Middleware provides **no** authorization checks. Any files served by Static Files Middleware, including those under *wwwroot*, are publicly available. For an approach to secure static files, see . -If the request isn't handled by the Static File Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. +If the request isn't handled by the Static Files Middleware, it's passed on to the Authentication Middleware (), which performs authentication. Authentication doesn't short-circuit unauthenticated requests. Although Authentication Middleware authenticates requests, authorization (and rejection) occurs only after MVC selects a specific Razor Page or MVC controller and action. -The following example demonstrates a middleware order where requests for static files are handled by Static File Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. +The following example demonstrates a middleware order where requests for static files are handled by Static Files Middleware before Response Compression Middleware. Static files aren't compressed with this middleware order. The Razor Pages responses can be compressed. ```csharp public void Configure(IApplicationBuilder app) { - // Static files aren't compressed by Static File Middleware. + // Static files aren't compressed by Static Files Middleware. app.UseStaticFiles(); app.UseRouting();