You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
I want to serve .apk files in my ASP.NET Core MVC project, and I can't since it returns 404.
I created a simple ASP.NET Core MVC project using default template in VS 2017, and added the .apk file to wwwroot folder, and then I tried to reach it using /application.apk path, and it didn't work, while /favicon.ico works, and other static contents in that directory work, because in the default template app.UseStaticFiles() is called.
I then tried to change configurations, brought static contents out of wwwroot folder and put the application.apk in the root directory of the project (one folder up from wwwroot) and configured the project using:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory())
});
Again no result. I get 404.
Then I created a Web.config file and added this MIME Type:
The static file middleware understands almost 400 known file content types. If the user requests a file of an unknown file type, the static file middleware returns a HTTP 404 (Not Found) response.
If you want to serve APK-files using the static files middleware, you can either turn on ServeUnknownFileTypes, or add the extension using FileExtensionContentTypeProvider.
Adding extra extensions using FileExtensionContentTypeProvider (recommended)
But be aware that this is discouraged as it could be a security risk:
Enabling ServeUnknownFileTypes is a security risk. It's disabled by default, and its use is discouraged. FileExtensionContentTypeProvider provides a safer alternative to serving files with non-standard extensions.
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.
I want to serve .apk files in my ASP.NET Core MVC project, and I can't since it returns 404.
I created a simple ASP.NET Core MVC project using default template in VS 2017, and added the
.apk
file towwwroot
folder, and then I tried to reach it using/application.apk
path, and it didn't work, while/favicon.ico
works, and other static contents in that directory work, because in the default templateapp.UseStaticFiles()
is called.I then tried to change configurations, brought static contents out of
wwwroot
folder and put theapplication.apk
in the root directory of the project (one folder up fromwwwroot
) and configured the project using:Again no result. I get 404.
Then I created a Web.config file and added this MIME Type:
Still, doesn't serve the .apk file.
What should I do?
The text was updated successfully, but these errors were encountered: