I'm sure I'm treading in the steps of many before but can't seem to solve this one issue. The goal is to create a file upload page for an ASP.NET 2.0 site that has a realtime progress bar (for potentially multiple files).
I've already implemented and tested most parts of the solution. But stupidly, I can't seem to get it to all work together.
Built a custom HttpModule that handles PreRequestHandlerExecute event (originally used BeginRequest--but I wanted access to Session) for the relevant requests and parses the incoming form post data in chunks using HttpWorkerRequest object. Realtime progress is saved to Session.
Built web service in the same application that offers ScriptMethod returning JSON to a jQuery request with progress information it extracts from the Session. Tested this and it works.
My issue is I haven't been able to have the jQuery polling of the ScriptMethod in (2) occur while (1) is in process. The jQuery calls just seem to queue up somewhere and as soon as the upload has fully posted, they all return suddenly with "100%". So the async part isn't working.
Things I have tried:
- Submitting the file upload post with .ajaxForm() (the jQuery Forms plugin).
- Various scenarios of nesting using IFRAMEs.
- Having a separate page (in separate browser tab) run the polling jQuery while I submit my uploads from the first page. The polls still halt and queue up until after the first page completes.
I've seen other very similar solutions online that others claim worked for them, so it must be possible, and I'm just missing something basic.
UPDATE:
Problem has been solved and all is now working. Please see my own answer below regarding SessionState locking.