Download .apk file Asp.net website using mobile browser

/ / 7 Comments

Overview: Here in this article I let you know how to download the .apk file from the Asp.net website (WebApplication) by using your android mobile browser. Recently in my project, there is one requirement where I have to download the .apk file hosted in my Asp.net Web application.

In my Asp.net web page for downloading an APK file (android app) I simply inserted a `button` control and set the respective app path (URL), it works fine when I use to download it from my computer.

But the problem comes when same I access it from my android phone browser it gives errors (Instead of 605 kb it only downloads 22kb ie only HTML content, not actual apk file).

So after a small research, i figured out the solution and it to simple here it is that by adding
mimeType="application/vnd.android.package-archive

 Code to Download .apk file from asp.net website given as below:

Environment: My Application is hosted under Window server 2008r2 having IIS 7.  

Following the steps, you can Download the .apk file.

Step 1:  In .aspx page add hyperlink set navigateurl as file path
//*
<asp:HyperLink ID="lnkdwnload" runat="server" NavigateUrl="~/Application_Android/MyAndroidAppAame.apk">Download MyApp</asp:HyperLink> 
//*
Step 2: Web.config add mimeMap element under staticContent
//*
<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>
</system.webServer>
//*
Yeah, by adding mimemap in web.config file we are now able to download APK files from the android phone browser.

Thank you for reading, pls keep visiting this blog and share this in your network. Also, I would love to hear your opinions down in the comments.

PS: If you found this content valuable and want to thank me? 👳 Buy Me a Coffee

Subscribe to our newsletter

Get the latest and greatest from Codepedia delivered straight to your inbox.


Post Comment

Your email address will not be published. Required fields are marked *

7 Comments

  1. mudasir 06/08/2016 10:44:37
    your post was really helpful to me thanks
  2. Mrinal 02/15/2017 05:57:22
    Great , it resolved my big effort problem.
  3. ABRAR 04/11/2017 10:24:45
    APK file not downloading on Android 7.0 version from SharePoint Website
  4. Satinder singh 05/22/2017 16:43:00
    Hello ABRAR, Sorry never worked on SharePoint Website
  5. priya 06/29/2017 14:03:43
    can you give me code for it
  6. Satinder singh 07/11/2017 06:33:59
    Hi Priya, What code do you need? Here in the article have written the web.config code and default.aspx page code for downloading apk file in asp.net
  7. sachhin 03/06/2023 15:34:01
    thanks a lot for this apk post sir