views:

45

answers:

1

I am writing an upload handler (asp.net) to handle image uploads.

The aim is to check the image type and content size before the entire file is uploaded. So I cannot use the Request object directly as doing so loads the entire file input stream. I therefore use the HttpWorkerRequest.

However, I keep getting "The connection to the server was reset while the page was loading".

After quite a bit of investigation it has become apparent that when posting the file the call works only if the entire input stream is read.

This, of course, is exactly what I do not want to do :)

Can someone please tell me how I can close off the request without causing the "connection reset" issue and having the browser process the response?

+1  A: 

There is no way to do this, as this is how HTTP functions. The best you can do is slurp the data from the client (i.e. read it in chunks) and immediately forget about it. This should prevent your memory requirements from being hammered, though will hurt your bandwidth.

Mike Axiak
Thanks Mike. Since my upload is done using ajax (jquery form) I can still cause the call to fail so that the entire file is _not_ uploaded. I have another bit polling the status so I'll handle the failure there.
Eben Roux