Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir,
I am unable to download a apk files using asp.net c#. I attached the code for your reference. Its working fine in Mozilla firefox of system, but it shows download
incomplete in all android mobiles. Kindly give me the solution for this problem.
Default.aspx.cs
-----------------------
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ClearContent();
        Response.Clear();
        Response.ContentType = "application/msi";
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + WebConfigurationManager.AppSettings["filename"].ToString());
        Response.TransmitFile(Server.MapPath("~/apk/") + WebConfigurationManager.AppSettings["filename"].ToString());
        Response.End();
    }
}

Web.config
-------------------
XML
<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>
  </system.webServer>
    <appSettings>
        <add key="filename" value="MyApps.apk"/>
    </appSettings>
</configuration>
Posted
v2
Comments
ridoy 2-Aug-13 2:58am    
See http://satindersinght.blogspot.in/2012/06/download-apk-from-aspnet-website-using.html, http://stackoverflow.com/questions/11079015/error-downloading-apk-from-asp-net-website-using-android-phone-browser

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900