简体   繁体   中英

C# asp.net asynchronous function call after file is uploaded

I'm facing the following issue: I have a C# asp.net file upload form with a submit button. After the form is submitted the file is uploaded and post-processing is started. The point is that the post-processing can take up to several minutes.

I would like to create some kind of asynchronous call of the post-processing function with showing information to the user.

So, the steps should be:

  1. file form is submitted by user and upload is started
  2. after the file is uploaded some information is shown to the user (eg "Processing..." or some loading-bar animation, etc.)
  3. Meanwhile, the post-processing function is automatically started running in a background
  4. After the post-processing function is finished the user is automatically redirected to another page

When i was searching the Internet I've found several examples but mostly only about asynchrounous call of functions, asynchrounous file upload (PageAsync method, etc.).

Any idea or techniques I should use or some tutorial? Thanks in advance

That all depends on how fancy you want to get;

  1. Meta-refresh that reloads the page until the background operation is finished
  2. Some kind of ajax call that checks some resource for when the processing is done
  3. HTML5 websockets. if supported, which it probably isn't.

Personally I would use the number 2. and use jQuery to poll the upload page every 500ms or something.

The jquery/flash control uploadify will allow you to do this easily. They also provide a method for asynchronously calling a method on the event that the file upload completes as described in this comprehensive documentation .

I have looked at a lot of places for a good example, and this is the one I like the best so far.

It does not handle the uploading, but it does a fine job at showing real progress to the user and it is not difficult to implement http://inov8.wordpress.com/2010/08/29/c-asp-net-creating-an-asynchronous-threaded-worker-process-manager-and-updatepanel-progress-monitor-control/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM