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:

wwwroot/
├── css/        → Stylesheets
├── js/         → JavaScript files
├── images/     → Image assets
├── lib/        → Third-party libraries (e.g., Bootstrap, jQuery)


🔸 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:

 app.UseStaticFiles(); // Enables serving static files from wwwroot

Leave a Reply

Your email address will not be published. Required fields are marked *


Talk to us?

Post your blog

F.A.Q

Frequently Asked Questions