...

/

Enable a Website to Serve Static Content

Enable a Website to Serve Static Content

Learn about the static files in a web service, creating a folder for static resources, and configuring the ASP.NET Core application to handle static and default files.

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 giving it a globe icon.

Step 2: ...