使用asp.net c#下载apk文件的问题? [英] Problem in download a apk files using asp.net c#?

查看:133
本文介绍了使用asp.net c#下载apk文件的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我无法使用asp.net c#下载apk文件。我附上了代码供您参考。它在Mozilla firefox系统中运行良好,但它显示在所有Android手机中下载

不完整。请给我解决这个问题的方法。

Default.aspx.cs

-------------------- ---

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

-------------- -----


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>

推荐答案

Refer - 使用Android手机浏览器从Asp.net网站下载.apk [ ^ ]。它可能对你有帮助。
Refer - Download .apk from Asp.net website using android phone browser[^]. It might help you.


这篇关于使用asp.net c#下载apk文件的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆