You may get an HTTP Error 404 when browsing a static file like .apk (which should be downloaded to the client) after publishing your application to your account. This means there is no matched MIME type for the target file extension in the FileExtensionContentTypeProvider to process the request. You can add the specific MIME type from your application Program.cs file to solve the problem.
For example:
using Microsoft.AspNetCore.StaticFiles;
var builder = WebApplication.CreateBuilder(args);
...
var app = builder.Build();
...
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary<string, string>
{
{".apk", "application/vnd.android.package-archive"},
{".nupkg", "application/zip"}
})
});
...
app.Run();
Article ID: 2256, Created: June 15, 2023 at 9:01 PM, Modified: June 16, 2023 at 2:46 AM