Thứ Hai, 18 tháng 6, 2012

Download .apk from Asp.net website using android phone browser



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 their is one requirement to download .apk file. In my webapplication download page i inserted a button and set path it works fine when you use to download it from your computer, but a 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".

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>

Không có nhận xét nào:

Đăng nhận xét