J'ai une page utilisateurs qui téléchargent des fichiers à partir de là. Et lorsqu'un utilisateur clique sur le lien de téléchargement et termine le téléchargement du fichier, j'insère un nouvel enregistrement pour mon événement de téléchargement de fichier. (FileID, Date, blalbla ..)ASP.NET Response.End Problème
Mais il y a un problème avec mon script ... après le téléchargement commence et se termine, son ajout d'un nouvel enregistrement, mais après cela, son incendie déclenche à nouveau l'événement et de faire un nouveau record aussi. 1 téléchargement et 2 nouveaux enregistrements de téléchargement. voici mon script;
if (Page.Request.QueryString["FileID"] != null)
{
OleDbCommand command = new OleDbCommand("select * from Dosyalar where DosyaID=" + Page.Request.QueryString["FileID"].ToString(), veri.baglan());
string dosyaAdi = "";
int DosyaID = 0;
OleDbDataReader dr = command.ExecuteReader();
while (dr.Read())
{
dosyaAdi = Server.MapPath("formlar") + "\\" + dr["URL"].ToString();
DosyaID = Convert.ToInt32(dr["FileID"]);
}
dr.Close();
FileInfo dosya = new FileInfo(dosyaAdi);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + dosya.Name);
Response.AddHeader("Content-Length", dosya.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(dosyaAdi);
// INSERT A NEW RECORD
OleDbCommand ekle = new OleDbCommand("Insert into Indirilenler (FileID,Tarih) values (@p1,@p2)", veri.baglan());
ekle.Parameters.AddWithValue("p1", FileID);
ekle.Parameters.AddWithValue("p2", DateTime.Now.ToShortDateString());
ekle.ExecuteNonQuery();
Response.Flush();
Response.End();
Utilisez-vous OutputCache sur cette page? –
J'espère que ce lien ci-dessous vous aiderons ... http://stackoverflow.com/questions/10829168/can-we-use-response-flush-instead-of-response-end/17038408 # 17038408 – Viishnuu