title: download apk from own Webserver
body: <p>I am having problem with download my android application from my own web server.</p>
  
  <p>First I sent a html content with java script to ask Android phone to open my download link</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script&gt;
              window.onload=function()
              {{
                  window.location = "downloadURL";
              }}
          &lt;/script&gt;
      &lt;/head&gt;
  &lt;/html&gt;"
  </code></pre>
  
  <p>Android phone revice this java script will open the downloadURL </p>
  
  <p>On my server end, I am using .Net ASP</p>
  
  <p>I've set up the MIME content</p>
  
  <pre><code>Response.Cache.SetCacheability(HttpCacheability.NoCache);
  Response.ContentType = "application/vnd.android.package-archive";
  Response.AppendHeader("Content-Disposition", "attachment; filename=" + "MyApp.apk");
  Response.AppendHeader("Content-Length", "" + response.Application.Bytes.Length);
  Response.BinaryWrite(response.Application.Bytes);
  </code></pre>
  
  <p>The apk file which is MyApp.apk is about 1.5MB</p>
  
  <p>How ever, when I used Android emulator to download the app, the file size is only 4.25 KB, and the name is not MyApp.apk. It contains the name of my download link.</p>
  
  <p><img src="https://i.stack.imgur.com/7pxYn.jpg" alt="alt text"></p>
  
  <p>When I use Firefox to download my app, Firefox successfully download it with correct name and size.
  <img src="https://i.stack.imgur.com/bgxPC.jpg" alt="alt text">
  Please help me out!!
  Thanks</p>
  
  <p>When I debug my server, my server did sent out the application bytes with </p>
  
  <pre><code>Response.BinaryWrite(response.Application.Bytes);
  </code></pre>
  
  <p>I don't understand why, andorid emulator can not receive, intead it seems create its own apk file from the html content.</p>