concept static file in category asp.net

This is an excerpt from Manning's book ASP.NET Core in Action, Second Edition MEAP V04.
Kestrel is responsible for receiving the request data and constructing a C# representation of the request, but it doesn’t attempt to generate a response directly. For that, Kestrel hands the
HttpContext
to the middleware pipeline found in every ASP.NET Core application. This is a series of components that processes the incoming request to perform common operations such as logging, handling exceptions, or serving static files.
Figure 2.13 An overview of a request for a static file at /css/site.css for an ASP.NET Core application. The request passes through the middleware pipeline until it’s handled by the static file middleware. This returns the requested CSS file as the response, which passes back to the web server. The endpoint middleware is never invoked and never sees the request.
![]()
Generally speaking, each middleware component has a single primary concern. It will handle one aspect of a request only. Logging middleware will only deal with logging the request, authentication middleware is only concerned with identifying the current user, and static-file middleware is only concerned with returning static files.

This is an excerpt from Manning's book ASP.NET Core in Action.
Figure 2.12. An overview of a request for a static file at /css/site.css for an ASP.NET Core application. The request passes through the middleware pipeline until it’s handled by the static file middleware. This returns the requested CSS file as the response, which passes back to the web server. The MVC middleware is never invoked and never sees the request.
![]()
As I described previously, middleware consists of small components that execute in sequence when the application receives an HTTP request. They can perform a whole host of functions, such as logging, identifying the current user for a request, serving static files, and handling errors.
Generally speaking, each middleware component has a single primary concern. It will handle one aspect of a request only. Logging middleware will only deal with logging the request, authentication middleware is only concerned with identifying the current user, and static-file middleware is only concerned with returning static files (when requested).
Most web applications, including those with dynamic content, serve a number of pages using static files. Images, JavaScript, and CSS stylesheets are normally saved to disk during development and are served up when requested, normally as part of a full HTML page request.
For now, you’ll use StaticFileMiddleware to create an application that only serves static files from the wwwroot folder when requested, as shown in figure 3.5. In this example, a static HTML file called Example.html exists in the wwwroot folder. When you request the file using the /Example.html path, it’s loaded and returned as the response to the request.