0

我正在尝试构建一个下载视频文件的网页,它可以工作,但我的 android 智能手机有问题。有 2 种形式:IndexfrmDownloadFile

索引.aspx

public partial class Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //process code and redirect to frmDownloadFile.aspx
            Response.Redirect("frmDownloadFile.aspx?id=" + id + "&Name=" + name);
        }
}

具有 2 个属性重载(id 和 name)的 URL:

192.168.93.194/DownloadVideo/Index.aspx?id=0096170731874&name=video.3gp

索引表单重定向到:

frmDownloadFile.aspx:

public partial class frmDownloadFile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //cBusinessRules is a class where i put methods that perform database tasks
            cBusinessRules cb = new cBusinessRules();


            string req = Request.QueryString["name"];
            string fName = System.String.Format(@"C:\{0}", req);//since I've located the video file on C:\ directory
            FileInfo fi = new FileInfo(fName);
            long sz = fi.Length;

            Response.ClearContent();
            Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", System.IO.Path.GetFileName(fName)));
            Response.ContentType = "video/3gp";
            Response.TransmitFile(fName);

            //the function below calls a query to increment the number of times the video was downloaded
            cb.IncrementFlag(Request.QueryString["id"], Request.QueryString["name"]);
            Response.End();
        }
    }
}

现在,当我将 URL 启动到我的 android 浏览器中时,我注意到frmDownloadFile的页面加载被访问了两次,并且回发未设置为 true,这与我在台式计算机浏览器上测试时不同。此外,当我在 iphone 上测试它时,它被访问了 5 次......所以问题是视频下载的次数在数据库中增加了两次。有什么建议么?

4

0 回答 0