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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:56:23+00:00 2026-06-06T22:56:23+00:00

I have the following code which is used to upload large files (~6MB) to

  • 0

I have the following code which is used to upload large files (~6MB) to an ASP .NET MVC2 application. After the file is uploaded it can take 5 minutes to return a response from the controller.

During this time, IE9 does not show any sign that processing is not yet completed, i.e. user can select other file and re-post.

How do you inform the user that an operation is not completed and disable the submit button until the old file processing is completed?

<% using (Html.BeginForm("InvoiceImport", "Grid", 
               FormMethod.Post, new { enctype = "multipart/form-data" }))
{%>
<input name="uploadFile" type="file" />
<input type="submit" name='invoice' value='Read'/>
<%} %>

Controller:

[AcceptVerbs(HttpVerbs.Post)]
[Authorize]
ActionResult ImportFromFile(HttpPostedFileBase uploadFile)
{
    Server.ScriptTimeout = 30 * 60;
    var res = ImportFromFile(uploadFile.InputStream); // takes lot of time
    TempData["Message"] = uploadFile.FileName + " Readed records " + res;
    return RedirectToAction("Complete");
}

Update

I looks like the most important issue is to prevent duplicate submits.
I tried code below to prevent duplicate submits but for unknown reason Session[“Upload”] is null
if submit button is pressed in second time.
How to prevent duplicate submits ?

View added

 <% if (TempData["Message"]!=null) { %>
   setTimeout( function() {
     showMessage ( '<%= TempData["Message"] as string %>');
    }, 300 );
    <% } %>


Controller

ActionResult ImportFromFile(HttpPostedFileBase uploadFile)
    {

        if (Session["Upload"] != null)
        {
            // todo: why this point is never reached ?
            TempData["Message"] = Session["Upload"] + " Please wait file is being processed";
            return View();
        }

        Session.Add("Upload", uploadFile.FileName);
        Server.ScriptTimeout = 30 * 60;
        ImportFromFile(uploadFile.InputStream);
        TempData["Message"] = uploadFile.FileName + " completed";
        Session.Remove("Upload");
        return RedirectToAction("Complete");
    }
  • 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-06-06T22:56:25+00:00Added an answer on June 6, 2026 at 10:56 pm

    The simplest solution to your problem is to disable the button and fields using javascript. Do you have any javascript libraries like jQuery in our page?

    $('form').submit(function(){
       $(this).find('input').prop('disabled', true)
    });
    

    Something like that for jQuery. If you have several forms you might want to add an id to the form to target only this one.

    UPDATE:

    As the problem with resubmitting there are no dead simple solution:

    To avoid the F5 problem. Make sure to redirect after the POST. Which you do, but I guess if it takes long time they might press F5 meanwhile.

    A few solutions on top of my head to this problem.

    • (IF you are using SQL) Generate a guid that you place in a hidden field on the form page. Make this a unique column in the database and insert it with the rest of the information. If they try to resubmit SQL will protect you by throwing an exception you can handle.

    • There are alternatives to the above technique. Maybe you store those guids in a separate table and check against that or maybe in XML or cache or whatever.

    • When you submit the form add a timestamp with javascript. The first thing you do on the server is to make sure you are within x seconds from when the button was clicked.

    • While submiting (After the first submit) you could add a warning with javascript.

      window.onbeforeunload = function(){ return ‘Already saving! Please press no’; };

    This last solution is not safe att all but very easy to add.

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

Sidebar

Related Questions

I have the following code which will generate two pdf files containing plots to
I have the following code which utilises Guava's Files.readLines() method: List<String> strings = Lists.newArrayList();
I have the following code which is used to Push and Pend from a
I have the following code which is used to slidein/out a div (shopping basket)
I have the following javascript code in place which is used to give hover
I have the following code to create a ViewStack which is used as a
I have the following HTML code (which is placed within several files), which inserts
I have the following code which when used in a link goes forward to
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which

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.