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?