I'm editing a site created by another developer. Trying different ways to download some files I noticed this:
I took a random file and put the file in the root folder of the site
1) renaming the file "a.exe", if I browse to "www.mysite.com/a.exe" starts the file download.
2) renaming the file "a.pdf", if I browse to "www.mysite.com/a.pdf" browser tries to open the pdf.
3) renaming the file "a.txt", if I browse to "www.mysite.com/a.txt" starts the file download.
4) renaming the file "a.jpg", if I browse to "www.mysite.com/a.jpg" browser tries to display the image.
5) renaming the file "a.apk", if I browse to "www.mysite.com/a.apk" server responds with "404 - File or directory not found.".
but .... why? the file is the same, and is always in the same folder, why suddenly seems to "disappear"?
the previous developer had designed a server-side workarounds to make it possible to download apk file.
but I can not believe that to download a file I can not simply write
<a href="www.mysite.com/a.apk"> DOWNLOAD </ a>
because it works with all file types except with the apk file...
Found a solution! If we want to download an apk file we have to tell the site how it should behave. to do this add to web.config:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
later simply build a link in this way:
<a href="myappPath.apk">DOWNLOAD</a>
that's all!