Reputation: 11
Recently, ASP.NET Core 9 released a new middleware, app.MapStaticAssets();
, to enhance the delivery of static resources.
I’ve been deploying an ASP.NET Core MVC project on a Linux virtual machine, and everything works as expected, except for the static files (CSS, JS, images, etc.). However, using app.UseStaticFiles();
works perfectly.
Can anyone help me identify what I might be missing or misconfigured?
For your reference, here’s a snippet from my Nginx config file for serving static files:
# MIME type handling for static files
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
root /path/to/my/app/wwwroot;
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}```
Upvotes: 0
Views: 98