UseStaticFiles is an ASP.NET Core application-builder method that adds static-file middleware to the request pipeline. Without arguments, it serves matching files from wwwroot; matching requests receive file contents and response headers such as Content-Type and Content-Length, while other requests continue through the pipeline. section 7.1.5 section 15.4.1
Configure the middleware according to the URL and file-location mapping you need:
- Call app.UseStaticFiles() near the start of the pipeline so later components do not handle requests intended for static files. section 15.4.1
- Pass StaticFileOptions to select another file location with FileProvider and assign its URL prefix with RequestPath. section 15.4.1
- Use the string overload when only a RequestPath prefix is needed, or register multiple middleware instances for separate URL-to-folder mappings. section 15.4.1
- Customize content-type behavior with ContentTypeProvider or DefaultContentType, and adjust responses through OnPrepareResponse. section 15.4.1
Expose an additional static-files folder
var env = app.Environment; app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider($"{env.ContentRootPath}/staticfiles"), RequestPath = "/files" }); With hello.html stored in staticfiles, request /files/hello.html to receive that file. Keep the parameterless call as well when wwwroot should remain available.

