Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 211141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:04:07+00:00 2026-05-11T18:04:07+00:00

i got a page users downloading files from there.And when a user click download

  • 0

i got a page users downloading files from there.And when a user click download link and finish downloading file , i am insertin’ a new record for my File Download Counter event. (FileID,Date,blalbla..)

But there is problem with my script … after download starts and finish, its adding a new record but after this, its fires event again and making a new record too.So 1 download and 2 new download record. here is my 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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:04:08+00:00Added an answer on May 11, 2026 at 6:04 pm

    The problem is that the browser is actually making two requests to get the file. This is typical behaviour.

    Either you can turn OutputCaching on this page on. This should mean that the browser’s second request won’t hit your server, and thus only record one entry, but you also need to make sure that you don’t have the debug flag set in your web.config file.

    The other option is to detect the request type. I think that the first request the browser sends is often a HEAD request and not a GET, or POST. You could detect and handle these appropriately but I think the first option maybe more reliable.

    Also, you should really be coding this as a ASPX Handler not a page. This means you could avoid the response.Clear() and thus you don’t confuse the browser as to what the content type of the URI is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a web page where the user can add a new item to
I've got a user page, where user can change his settings ( users#edit ).
I've got an add product page for users to select a product from the
I've got a page where users can upload a HTML file for use as
In my website, I've got a download page. When the user clicks on the
I'm working on a site where I've got a page where a user can
I've got a simple form on a User page that allows a User, once
We've got the following situation, running from a single domain: Page A uses window.open()
I've got a an AJAX page request that uses a php file designed to
I got a user control containing a form. On a page that includes the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.