In the wwwroot folder I can access all files(images, java script, css, zip). But when I upload an apk file, it is not accessible. When I compress this apk file to zip I can download it
CodePudding user response:
AspNetCore uses this list of media types and according to this list, it does not know what an APK file is, so AspNetCore will return a 404 error.
To allow this, you can map your own. REF: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-6.0#fileextensioncontenttypeprovider
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".apk"] = "application/vnd.android.package-archive";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});