views:

87

answers:

1

I’m trying to get a handle on the exact process that occurs when a user posts data back to the server from an asp.net webform. Does the file upload always complete before postback starts or can some processing finish before the end of the request is finished.

As a part of this question how is it that some people are able to estimate the time it will take to upload a specific file since they would have to have at least some knowledge of what’s happening in the code and the file would then be assumed to not have completely uploaded?

A: 

Web apps that can estimate upload times and show progress are generally using a 3rd party plug-in that runs on the client to do the uploading (flash uploader, silverlight uploader, java plug-in, activeX control, etc.). These usually perform async postbacks and manage their own network connection to the server. It is usually the client-side code that is determinning the upload progess and speed and such though.

The standard HTTP support for file uploads through the HTML input control is not very intelligent. So if you are using the asp.net FileUpload control (which just renders an HTML input tag down to the browser) you will have a hard time getting at the request from the page's code behind until the entire upload of the file is complete.

However; you can intercept the request in an HttpModule before the complete file is uploaded. Some of the earlier events in the asp.net lifecycle will fire before the file upload completes, but honestly I don't know exactly how far into the request you get before it waits for the rest of the post data. I do know that BeginRequest gets called though (I've hooked up code here for file uploads before).

So yes, you can do some work here, but your information about the content of the incoming request will be very limited at that point.

Stephen M. Redd