After reading this article and this one can not handle Serve files in web root (.net core 3.1).
There is a CB folder in the webroot folder and I can browse any txt or png file it works fine but when I want to download an apk file it doesn't work and browser message files not found.
this is my folders structure:
-wwwroot
-CB
myfile.apk
installed “Microsoft.AspNetCore.StaticFiles” and used:
app.UseStaticFiles();
tested URL:
http://localhost:51405/cb/myfile.apk
From the second article, it explicity states to configure UseStaticFiles()
options via its parameter and specify that static files should be served even if the file type is unknown.
app.UseStaticFiles(new StaticFileOptions
{
ServeUnknownFileTypes = true
});
Like the article states, however, this is a pretty big security risk. Proceed with caution.