Search⌘ K
AI Features

Enable a Website to Serve Static Content

Explore how to enable a website built with ASP.NET Core to serve static content by creating a wwwroot folder, adding an index.html page with Bootstrap styling, and configuring middleware to serve static and default files. Understand browser interactions, URL routing for static and dynamic content, and basic web server setup to build more functional websites.

A website that only ever returns a single plain text message isn’t very useful. At a minimum, it should return static HTML pages, CSS that the web pages will use for styling, and any other static resources, such as images and videos. By convention, these files should be stored in a directory named wwwroot to keep them separate from the dynamically executing parts of our website project.

Create a folder for static files and a web page

We will now create a folder for our static website resources and a basic index page that uses Bootstrap for styling:

Step 1: In the Northwind.Web project or folder, create a folder named wwwroot. Note that Visual Studio recognizes it as a special folder type by ...