UseStaticFiles
UseStaticFiles is an ASP.NET Core application-builder method that adds middleware for serving static files from the application.
ASP.NET Core in Action, 3e
UseStaticFiles is an ASP.NET Core application-builder method that adds static-file serving middleware to the request pipeline.
- How it is used
- Adds static-file serving to an ASP.NET Core request pipeline.
- How deep it goes
- Explains registration, wwwroot lookup, successful responses, pass-through behavior, and automatic 404 handling.
- Examples
- Uses Program.cs, wwwroot/moon.jpg, missing.jpg, and browser responses to demonstrate serving and failure cases.
- What you can do after
- Operate/configure an ASP.NET Core pipeline that serves existing files and returns 404 responses for missing files.
Read how ASP.NET Core in Action, 3e explains UseStaticFiles →
Pro ASP.NET Core 7, Tenth Edition
UseStaticFiles is an ASP.NET Core application-builder method that adds static-file serving to the request pipeline.
- How it is used
- Adds static-file serving to the ASP.NET Core request pipeline, primarily for files under wwwroot.
- How deep it goes
- Explains default behavior, middleware ordering, response headers, configurable locations, URL prefixes, MIME handling, and multiple mappings.
- Examples
- Uses wwwroot files, a static.html request, and a PhysicalFileProvider mapping from /files to staticfiles.
- What you can do after
- Operate/configure static-file serving with default wwwroot behavior or customized file providers, URL prefixes, and response options.
Read how Pro ASP.NET Core 7, Tenth Edition explains UseStaticFiles →
Related concepts
- staticfilemiddlewareuses · Static file middleware is an ASP.NET Core middleware component that serves existing files from configured locations in response to matching requests.
- static fileconfigures · A static file is a preexisting digital resource served in its stored form rather than generated dynamically for each request.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

