ビデオファイルをダウンロードする Web ページを作成しようとしていますが、動作していますが、Android スマートフォンに問題があります。2 つの形式を持つ: IndexとfrmDownloadFile
インデックス.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();
}
}
}
Android ブラウザーで URL を起動すると、frmDownloadFileのページ ロードが 2 回アクセスされ、デスクトップ コンピューターのブラウザーでテストしたときとは異なり、ポストバックが true に設定されていないことに気付きました。その上、iPhoneでテストすると、5回アクセスされます...そのため、問題は、ビデオがダウンロードされる回数がデータベースで2回増加することです。助言がありますか?