Download .apk file Asp.net website using mobile browser

 Overview: Here in this article I let you know how to download .apk file from Asp.net website (WebApplication) by using your android mobile browser. Recently in my project there is one requirement where i have to download .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 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 download 22kb ie only HTML content not actual apk file).

So after 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 .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 download APK file from android phone browser.

Hope you enjoyed this tutorial. If you have any recommendations, please let us know what you think in the comment section below!

Share:    
Satinder Singh

Hi all, am Founder and Author of Codepedia.info, also atypical polyglot programmer from Bombay, India. I have a passion to create, solve, and deploy software applications.
       ForEach ( minute in MyLife ) { myExperience++ ; }


2 comments on “Download .apk file Asp.net website using mobile browser”


Post Comment


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