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 4612516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:24:48+00:00 2026-05-22T01:24:48+00:00

I have a file upload on my .NET website. I used the FileUpload .NET

  • 0

I have a file upload on my .NET website. I used the FileUpload .NET control for the upload, and set the target of the form to a hidden iframe. I use client-side script to submit the form, then display a progress bar on the page, which does an AJAX request to an ashx file on the same server and updates the progress bar every second.

Here’s the part of the code for when the file is uploading –

    string fileString = StringGenerator.GenerateString(8);
    System.IO.Stream fileStream = System.IO.File.Create(fileRoot+ fileString + ".mp3");
    System.IO.Stream inputStream = fileUpload.PostedFile.InputStream;
    byte[] buffer = new byte[256];
    int read;
    if(StaticProgress.Progress.ContainsKey(trackId)) StaticProgress.Progress[trackId] = 0d;
    else StaticProgress.Progress.Add(trackId, 0d);
    int totalRead = 0;
    long length = inputStream.Length;
    while ((read = inputStream.Read(buffer, 0, buffer.Length)) > 0)
    {
        totalRead += read;
        fileStream.Write(buffer, 0, read);
        StaticProgress.Progress[trackId] = (double)totalRead / (double)length;
    }

StaticProgress.Progress is a property which returns a static Dictionary.
Here is the code in the ashx file that gets the progress of the

    context.Response.ContentType = "text/javascript";
    int id;
    if(!int.TryParse(context.Request.QueryString["id"], out id) || !StaticProgress.Progress.ContainsKey(id))
        context.Response.Write("{\"error\":\"ID not found\"}");
    else
        context.Response.Write("{\"id\":\"" + id + "\",\"decimal\":" + StaticProgress.Progress[id] + "}");

Here I always “ID not found” while the file is uploading, but when the file has finished uploading, I get a successful – decimal : 1.

I’ve tried using session variables before this and got the same result. I’ve tried using a public static (thread safe?) Dictionary, but I get the same result. Has anyone came across anything like this before? Does the code not execute until the client request has been fully received?

  • 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-22T01:24:49+00:00Added an answer on May 22, 2026 at 1:24 am

    The standard file upload control provides no progress abilities – it does not receive the file until the file has been fully received by the server. By the time you open the stream on the .PostedFile, the file has been completely uploaded.

    There are a number of better solutions to uploading discussed here.

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

Sidebar

Related Questions

I have used file upload control of asp.net but I am getting empty string
I have a form that excepts a file upload in ASP.NET. I need to
I have a .NET webform that has a file upload control that is tied
I have a tutorial from a website Net Tuts which is used to upload
I have a FileUpload Control and a image control on asp.net page as follows
I have an ASP.NET Repeater control with a FileUpload Control in its item template.
I have a file upload group in a form and I'd like to be
I have a file upload form that is being posted back to a servlet
I have a file upload control <input id=File1 type=file /> in my page... How
I have a asp.net website which is supposed to upload files to a handler

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.