Prabu Spark

Prabu Spark

  • NA
  • 124
  • 199.5k

Problem in download a apk files using asp.net c#?

Aug 2 2013 2:26 AM
 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
-----------------------

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 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>

Answers (1)