In ASP.NET Core, the wwwroot
folder is treated as the web root by default. It is the designated location for storing static files such as JavaScript, CSS, images, fonts, and libraries. Files placed here are publicly accessible over HTTP using a path relative to this folder.
This is a key change from classic ASP.NET, where static files could be served from any folder within the project. In ASP.NET Core, only files within wwwroot
can be served by default. All other directories are protected and not directly accessible via HTTP requests.
📁 Organizing Static Files
It is recommended to organize your static files into subfolders within wwwroot
based on their type—for example:
🔸 How Static Files are Served
To enable static file serving, your app must include this middleware in Startup.cs
(for older versions) or Program.cs
: