473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

*Impossible* to build an upload progress meter using ASP.NET. Can you prove me wrong?

**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible
to build a file upload progress meter using ASP.NET" **** First person
to prove me wrong gets "All Time .NET Programming GOD" listing in my
address book and (optionally) their name listed on my "news" page of
my birtle.com website (listed as "Jane Smith is a Programming GOD")
for at least a month. Why not take a moment to read more and possibly
boost your ego to all time highs and help me out at the same time?

I've sucessfully built a progress meter with ASP classic using
examples floating on the net, but failed using the same method using
ASP.NET. I have not seen any working upload progress meter using
ASP.NET although I have searched long and hard.

Here's the sample code that shows the "critical limitation" of ASP.NET
which seems to block all attempts at a progress meter. Note this is a
change in behavior from ASP classic:

... On_BeginRequest(...) // <-- add to your global.asax or whatever
{
////This line gets executed right when the HTTP connection is
// opened (before even any of the HTTP request is read):
Application["UploadState"] = "started";
...

////Following line thread blocks until entire request is read
// (even though I have only requested to read the first 10
// bytes of the incoming HTTP request stream (POSTed data).)
// Note this could be 30 minutes if the uploaded file is
// large and/or connection is slow. Also note that in ASP
// classic the same call will return immediately after the
// first 10 bytes are read (no thread block):
byte[] firstTenBytes = Request.BinaryRead(10);

////Following line executes only after entire HTTP request
// has been received (THAT'S A PROBLEM!):
Application["UploadState"] = "finished";

////This line would also thread block, if the BinaryRead
// line were commented out:
Stream request = Request.InputStream;

// Note I have not even called any methods on the
// InputStream - it seems the InputStream property
// itself is thread blocking.

////This line does NOT thread block...
Request.Filter = new MyFilterClass();

////...but MyFilterClass is never called by ASP.NET
// (the Read method in particular) until the entire
// request is read, thus the Filter class seems
// useless of my purposes.

} ...

In the ASP version, you stick Request.BinaryRead into a loop until you
read all the bytes. ASP classic blocks BinaryRead only until the bytes
specifed are read, so in your loop you can add a line like:

Application["BytesRead" & strUploadId] = iBytesRead

Then in a second browser window you can hit a page GetUploadStatus.asp
which would return the value of the Application variable. Please note
I have hand-coded the above, simplified example because the real code
is much more complicated and references a bunch of other classes which
would only serve as distractions and flamebait for all the
hypercritical newsreaders out there.

I also tried...
* The same code in an HttpHandler
* The same code in an XML Web Service
* The same code in various other event handlers (onload, oninit, etc.)

The problem seems to be in the HttpContext/HttpRequest classes thus no
matter where you stick the code, the thread blocking occurs.

I am trying for a 100% ASP.NET solution on the server side although if
somebody can send over some VB or C++ or whatever code that works or
even recommend another approach I'll consider you highly for
"Programming GOD" listing.

I posted this previously under the thread "Accessing
Request.InputStream / Request.BinaryRead *as the request is occuring*:
How???". Here's a few notes before you hit the reply key:

* HttpAsyncHandler appears to be used when the *response*, not the
request, is to be handled asynchronously, thus the class doesn't help.

* You cannot use Session to store the upload progress because pages
that use Session are serialized, thus the call to
GetUploadProgress.aspx in the second window would queue until the POST
acceptor main window finishes.

* The purpose is a rough estimate for an upload that would occur over
a long time (slow connection and/or very large file) thus latency
between byte sent from the client and byte received on the server and
when my thread is notified and finally round trip of the secondary
window to get the status should all be no problem. As long as the
client can see some sort of rough estimate that changes every few
seconds it's fine.

* I already searched extensively over several weeks and spent several
days trying to find a workaround and have failed. Although I am only a
humble staff programming, I am not a newbie - I have more than 6 years
experience with ASP, JSP, Java Servlets, ASP.NET, ATL C++ etc. and I'm
not often stumpted. **** Are you the programming GOD that can help me?
****

Thanks for your time.
Brian Birtle
Web Application Developer - VPD Group
International Technigroup Incorporated
http://www.iti-global.com/
http://birtle.com/

(The views above don't necessarily reflect ITI, blah blah blah...)
Nov 17 '05 #1
3 2633
Why not upload to your own webserver written in c# running on a different
port and query this for the progress?

I havent look into this much this is just the first idea that poped into my
head after reading the problems below.

Steve
"Brian Birtle" <br**********@hotmail.com> wrote in message
news:b5**************************@posting.google.c om...
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible
to build a file upload progress meter using ASP.NET" **** First person
to prove me wrong gets "All Time .NET Programming GOD" listing in my
address book and (optionally) their name listed on my "news" page of
my birtle.com website (listed as "Jane Smith is a Programming GOD")
for at least a month. Why not take a moment to read more and possibly
boost your ego to all time highs and help me out at the same time?

I've sucessfully built a progress meter with ASP classic using
examples floating on the net, but failed using the same method using
ASP.NET. I have not seen any working upload progress meter using
ASP.NET although I have searched long and hard.

Here's the sample code that shows the "critical limitation" of ASP.NET
which seems to block all attempts at a progress meter. Note this is a
change in behavior from ASP classic:

... On_BeginRequest(...) // <-- add to your global.asax or whatever
{
////This line gets executed right when the HTTP connection is
// opened (before even any of the HTTP request is read):
Application["UploadState"] = "started";
...

////Following line thread blocks until entire request is read
// (even though I have only requested to read the first 10
// bytes of the incoming HTTP request stream (POSTed data).)
// Note this could be 30 minutes if the uploaded file is
// large and/or connection is slow. Also note that in ASP
// classic the same call will return immediately after the
// first 10 bytes are read (no thread block):
byte[] firstTenBytes = Request.BinaryRead(10);

////Following line executes only after entire HTTP request
// has been received (THAT'S A PROBLEM!):
Application["UploadState"] = "finished";

////This line would also thread block, if the BinaryRead
// line were commented out:
Stream request = Request.InputStream;

// Note I have not even called any methods on the
// InputStream - it seems the InputStream property
// itself is thread blocking.

////This line does NOT thread block...
Request.Filter = new MyFilterClass();

////...but MyFilterClass is never called by ASP.NET
// (the Read method in particular) until the entire
// request is read, thus the Filter class seems
// useless of my purposes.

} ...

In the ASP version, you stick Request.BinaryRead into a loop until you
read all the bytes. ASP classic blocks BinaryRead only until the bytes
specifed are read, so in your loop you can add a line like:

Application["BytesRead" & strUploadId] = iBytesRead

Then in a second browser window you can hit a page GetUploadStatus.asp
which would return the value of the Application variable. Please note
I have hand-coded the above, simplified example because the real code
is much more complicated and references a bunch of other classes which
would only serve as distractions and flamebait for all the
hypercritical newsreaders out there.

I also tried...
* The same code in an HttpHandler
* The same code in an XML Web Service
* The same code in various other event handlers (onload, oninit, etc.)

The problem seems to be in the HttpContext/HttpRequest classes thus no
matter where you stick the code, the thread blocking occurs.

I am trying for a 100% ASP.NET solution on the server side although if
somebody can send over some VB or C++ or whatever code that works or
even recommend another approach I'll consider you highly for
"Programming GOD" listing.

I posted this previously under the thread "Accessing
Request.InputStream / Request.BinaryRead *as the request is occuring*:
How???". Here's a few notes before you hit the reply key:

* HttpAsyncHandler appears to be used when the *response*, not the
request, is to be handled asynchronously, thus the class doesn't help.

* You cannot use Session to store the upload progress because pages
that use Session are serialized, thus the call to
GetUploadProgress.aspx in the second window would queue until the POST
acceptor main window finishes.

* The purpose is a rough estimate for an upload that would occur over
a long time (slow connection and/or very large file) thus latency
between byte sent from the client and byte received on the server and
when my thread is notified and finally round trip of the secondary
window to get the status should all be no problem. As long as the
client can see some sort of rough estimate that changes every few
seconds it's fine.

* I already searched extensively over several weeks and spent several
days trying to find a workaround and have failed. Although I am only a
humble staff programming, I am not a newbie - I have more than 6 years
experience with ASP, JSP, Java Servlets, ASP.NET, ATL C++ etc. and I'm
not often stumpted. **** Are you the programming GOD that can help me?
****

Thanks for your time.
Brian Birtle
Web Application Developer - VPD Group
International Technigroup Incorporated
http://www.iti-global.com/
http://birtle.com/

(The views above don't necessarily reflect ITI, blah blah blah...)

Nov 17 '05 #2
Look at custom ASP.NET Request Processing in MSDN.

Steve

"Brian Birtle" <br**********@hotmail.com> wrote in message
news:b5**************************@posting.google.c om...
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible
to build a file upload progress meter using ASP.NET" **** First person
to prove me wrong gets "All Time .NET Programming GOD" listing in my
address book and (optionally) their name listed on my "news" page of
my birtle.com website (listed as "Jane Smith is a Programming GOD")
for at least a month. Why not take a moment to read more and possibly
boost your ego to all time highs and help me out at the same time?

I've sucessfully built a progress meter with ASP classic using
examples floating on the net, but failed using the same method using
ASP.NET. I have not seen any working upload progress meter using
ASP.NET although I have searched long and hard.

Here's the sample code that shows the "critical limitation" of ASP.NET
which seems to block all attempts at a progress meter. Note this is a
change in behavior from ASP classic:

... On_BeginRequest(...) // <-- add to your global.asax or whatever
{
////This line gets executed right when the HTTP connection is
// opened (before even any of the HTTP request is read):
Application["UploadState"] = "started";
...

////Following line thread blocks until entire request is read
// (even though I have only requested to read the first 10
// bytes of the incoming HTTP request stream (POSTed data).)
// Note this could be 30 minutes if the uploaded file is
// large and/or connection is slow. Also note that in ASP
// classic the same call will return immediately after the
// first 10 bytes are read (no thread block):
byte[] firstTenBytes = Request.BinaryRead(10);

////Following line executes only after entire HTTP request
// has been received (THAT'S A PROBLEM!):
Application["UploadState"] = "finished";

////This line would also thread block, if the BinaryRead
// line were commented out:
Stream request = Request.InputStream;

// Note I have not even called any methods on the
// InputStream - it seems the InputStream property
// itself is thread blocking.

////This line does NOT thread block...
Request.Filter = new MyFilterClass();

////...but MyFilterClass is never called by ASP.NET
// (the Read method in particular) until the entire
// request is read, thus the Filter class seems
// useless of my purposes.

} ...

In the ASP version, you stick Request.BinaryRead into a loop until you
read all the bytes. ASP classic blocks BinaryRead only until the bytes
specifed are read, so in your loop you can add a line like:

Application["BytesRead" & strUploadId] = iBytesRead

Then in a second browser window you can hit a page GetUploadStatus.asp
which would return the value of the Application variable. Please note
I have hand-coded the above, simplified example because the real code
is much more complicated and references a bunch of other classes which
would only serve as distractions and flamebait for all the
hypercritical newsreaders out there.

I also tried...
* The same code in an HttpHandler
* The same code in an XML Web Service
* The same code in various other event handlers (onload, oninit, etc.)

The problem seems to be in the HttpContext/HttpRequest classes thus no
matter where you stick the code, the thread blocking occurs.

I am trying for a 100% ASP.NET solution on the server side although if
somebody can send over some VB or C++ or whatever code that works or
even recommend another approach I'll consider you highly for
"Programming GOD" listing.

I posted this previously under the thread "Accessing
Request.InputStream / Request.BinaryRead *as the request is occuring*:
How???". Here's a few notes before you hit the reply key:

* HttpAsyncHandler appears to be used when the *response*, not the
request, is to be handled asynchronously, thus the class doesn't help.

* You cannot use Session to store the upload progress because pages
that use Session are serialized, thus the call to
GetUploadProgress.aspx in the second window would queue until the POST
acceptor main window finishes.

* The purpose is a rough estimate for an upload that would occur over
a long time (slow connection and/or very large file) thus latency
between byte sent from the client and byte received on the server and
when my thread is notified and finally round trip of the secondary
window to get the status should all be no problem. As long as the
client can see some sort of rough estimate that changes every few
seconds it's fine.

* I already searched extensively over several weeks and spent several
days trying to find a workaround and have failed. Although I am only a
humble staff programming, I am not a newbie - I have more than 6 years
experience with ASP, JSP, Java Servlets, ASP.NET, ATL C++ etc. and I'm
not often stumpted. **** Are you the programming GOD that can help me?
****

Thanks for your time.
Brian Birtle
Web Application Developer - VPD Group
International Technigroup Incorporated
http://www.iti-global.com/
http://birtle.com/

(The views above don't necessarily reflect ITI, blah blah blah...)

Nov 17 '05 #3
JM
i chose not to spend a weak dealing with this due to the many other
limitations with asp.net file uploading like preventing to large files from
getting uploaded and being able to gracefully handle the error, and the fact
that is holds down a thread while uploading the file. i think you will
regret using this if you do. i use softartisans fileup component and it
works great and has a file progress monitor.
"Brian Birtle" <br**********@hotmail.com> wrote in message
news:b5**************************@posting.google.c om...
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible
to build a file upload progress meter using ASP.NET" **** First person
to prove me wrong gets "All Time .NET Programming GOD" listing in my
address book and (optionally) their name listed on my "news" page of
my birtle.com website (listed as "Jane Smith is a Programming GOD")
for at least a month. Why not take a moment to read more and possibly
boost your ego to all time highs and help me out at the same time?

I've sucessfully built a progress meter with ASP classic using
examples floating on the net, but failed using the same method using
ASP.NET. I have not seen any working upload progress meter using
ASP.NET although I have searched long and hard.

Here's the sample code that shows the "critical limitation" of ASP.NET
which seems to block all attempts at a progress meter. Note this is a
change in behavior from ASP classic:

... On_BeginRequest(...) // <-- add to your global.asax or whatever
{
////This line gets executed right when the HTTP connection is
// opened (before even any of the HTTP request is read):
Application["UploadState"] = "started";
...

////Following line thread blocks until entire request is read
// (even though I have only requested to read the first 10
// bytes of the incoming HTTP request stream (POSTed data).)
// Note this could be 30 minutes if the uploaded file is
// large and/or connection is slow. Also note that in ASP
// classic the same call will return immediately after the
// first 10 bytes are read (no thread block):
byte[] firstTenBytes = Request.BinaryRead(10);

////Following line executes only after entire HTTP request
// has been received (THAT'S A PROBLEM!):
Application["UploadState"] = "finished";

////This line would also thread block, if the BinaryRead
// line were commented out:
Stream request = Request.InputStream;

// Note I have not even called any methods on the
// InputStream - it seems the InputStream property
// itself is thread blocking.

////This line does NOT thread block...
Request.Filter = new MyFilterClass();

////...but MyFilterClass is never called by ASP.NET
// (the Read method in particular) until the entire
// request is read, thus the Filter class seems
// useless of my purposes.

} ...

In the ASP version, you stick Request.BinaryRead into a loop until you
read all the bytes. ASP classic blocks BinaryRead only until the bytes
specifed are read, so in your loop you can add a line like:

Application["BytesRead" & strUploadId] = iBytesRead

Then in a second browser window you can hit a page GetUploadStatus.asp
which would return the value of the Application variable. Please note
I have hand-coded the above, simplified example because the real code
is much more complicated and references a bunch of other classes which
would only serve as distractions and flamebait for all the
hypercritical newsreaders out there.

I also tried...
* The same code in an HttpHandler
* The same code in an XML Web Service
* The same code in various other event handlers (onload, oninit, etc.)

The problem seems to be in the HttpContext/HttpRequest classes thus no
matter where you stick the code, the thread blocking occurs.

I am trying for a 100% ASP.NET solution on the server side although if
somebody can send over some VB or C++ or whatever code that works or
even recommend another approach I'll consider you highly for
"Programming GOD" listing.

I posted this previously under the thread "Accessing
Request.InputStream / Request.BinaryRead *as the request is occuring*:
How???". Here's a few notes before you hit the reply key:

* HttpAsyncHandler appears to be used when the *response*, not the
request, is to be handled asynchronously, thus the class doesn't help.

* You cannot use Session to store the upload progress because pages
that use Session are serialized, thus the call to
GetUploadProgress.aspx in the second window would queue until the POST
acceptor main window finishes.

* The purpose is a rough estimate for an upload that would occur over
a long time (slow connection and/or very large file) thus latency
between byte sent from the client and byte received on the server and
when my thread is notified and finally round trip of the secondary
window to get the status should all be no problem. As long as the
client can see some sort of rough estimate that changes every few
seconds it's fine.

* I already searched extensively over several weeks and spent several
days trying to find a workaround and have failed. Although I am only a
humble staff programming, I am not a newbie - I have more than 6 years
experience with ASP, JSP, Java Servlets, ASP.NET, ATL C++ etc. and I'm
not often stumpted. **** Are you the programming GOD that can help me?
****

Thanks for your time.
Brian Birtle
Web Application Developer - VPD Group
International Technigroup Incorporated
http://www.iti-global.com/
http://birtle.com/

(The views above don't necessarily reflect ITI, blah blah blah...)

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ron | last post by:
I spent the last couple of days setting up a progress indicator for a private site that only does a couple uploads a day. After figuring out there was no way to set the 'upload_tmp_dir' or...
13
by: Martin Mrazek | last post by:
Hi, I check data validity in html form by JS. Something like for (i=0; i<document.form.elements.length; i++) { chechkValidity(i); } Unfortunately, the form has about two thousands elements...
8
by: Brian Henry | last post by:
I created a smooth progress bar with this code.. but if you update the values in a row quickly of it and watch it on screen it flickers... how would i change this to reduce the flickering?...
4
by: bfulford | last post by:
I have a macro that needs to have a progress meter displayed since it is long running. I moved the Macro's instructions to a table and pulled those records into a recordset that is looped through....
6
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
1
by: Marko Vuksanovic | last post by:
I used the following code for implementing a file upload progress indicator, using UpdateProgress Panel, though I have a problem that FileUpload.Has File always returns false. Any suggestions what...
7
by: Shelly | last post by:
I do what most programmers do -- we steal code from stuff we have written before, or accept code from others that works, before we attempt to write something altogether new. On a previous...
2
by: Adam R | last post by:
Looking for an upload progress meter which can works with 'non-patched' PHP4. -- -------------------------------------- Adam Raszkiewicz Brothers-in-arts.com...
23
ADezii
by: ADezii | last post by:
Many Access Users fail to realize that it has a built-in Progress Meter that can display the relative completion percentage of various processes. It is fairly limited, but nonetheless, does provide...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.