0

I am trying to build a web page that downloads a video file, its working but I have issues in my android smartphone. having 2 forms: Index and frmDownloadFile

Index.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);
        }
}

The URL having 2 attributes overload (id and name):

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

Index form redirects to:

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();
        }
    }
}

now, when i launch the URL into my android browser, I notice that the page load of frmDownloadFile is visited twice, and the postback is not set to true, unlike when I tested it on my desktop computer browser. Besides, when I test it on an iphone, it is visited 5 times... so the problem is that the number of times the video is downloaded increments twice in the Database. Any suggestions?

Samer_Azar
  • 413
  • 2
  • 9
  • 32
  • Isn't it strange that you expect a postback in the first place? How do you redirect from the index.aspx? – rene May 11 '13 at 09:20
  • First if is called two times it maybe a client side issue, how do you make this call ? (witl link, javascript ?). Second use a handler for the download: http://stackoverflow.com/questions/10912164/what-is-the-best-way-to-download-file-from-server/10912955#10912955 – Aristos May 11 '13 at 09:24
  • I edited the question, this is the full code... – Samer_Azar May 11 '13 at 09:34

0 Answers0