The wwwroot folder is the conventional location for static content in an ASP.NET Core project. Put files there when they do not need to be generated for every request, such as HTML, images, CSS stylesheets, and JavaScript files. Dynamic content, by contrast, is generated in response to a user's identity or actions. section 15.4
To serve a static HTML file:
- Create wwwroot in the project and add demo.html. Give the file its .html extension when creating it manually. section 4.2
- For the minimal application, add app.UseStaticFiles() to Program.cs. This enables responses using files in wwwroot. section 4.3
- Run the application and request http://localhost:5000/demo.html to see the file in a browser. section 4.3
Listing 4.4 Adding a statement in the Program.cs file in the MyProject folder
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.UseStaticFiles();
app.Run();
The Program.cs listing shows where app.UseStaticFiles() fits in the minimal application. section 4.3
A stylesheet for validation errors
Place styles.css in wwwroot/css and link to it with href="/css/styles.css". The URL omits wwwroot: in the configured application, requests for static content map to that folder. The stylesheet can highlight inputs marked with input-validation-error after a validation failure. section 3.2.9 section 3.2.9
Do not confuse the folder convention with the setup needed to serve its files. The minimal application adds app.UseStaticFiles() explicitly; the configured validation example already supports static-content requests. section 4.3 section 3.2.9

