Tutorials ASP.NET Core MVC Mastery
wwwroot & Static Files
On this page
Mastering wwwroot: Secure Static File Delivery
1. Why wwwroot? (The "Web Root" Standard)
In legacy ASP.NET, your entire project was public. In ASP.NET Core, ONLY the wwwroot folder is accessible from the web. This is the **First Firewall** that protects your project configuration (C# code, appsettings.json) from hackers.
2. Middleware: app.UseStaticFiles()
For your CSS and JS to load, you must enable this middleware in Program.cs. Standard for all applications.
Architect Insight: Client-Side Cache Headers
Senior architects use StaticFileOptions to set long-term **Cache-Control** headers (e.g. 1 year). This tells browsers to keep your images/JS in memory, reducing server load by **80%** or more for your 1M+ user application.