Administrator
|
I just reviewed the code and realized that I stopped throwing errors on cancelled requests because those errors get logged in some environments and I was getting too many questions about the log messages. Sorry for misleading you. The good news is that the Application_EndRequest should still fire. To distinguish between a successful and unsuccessful upload, set HttpContext.Current.Items["UploadedSucceeded"] in your upload page and then check for it in the Application_EndRequest handler.
Alternatively, to be notified when each upload completes you would indeed need to create a custom UploadStorageProvider. If you just derive from an existing provider (e.g. FilesystemUploadStorageProvider) and override CreateUploadedFile() to invoke your desired event and then call base.CreateUploadedFile(), then your handler should be able to use UploadModule.Files to access all preceding files.
Regardless of which approach you take, if you need access to the session, things get more complicated. That's because at the time NeatUpload is receiving the files, ASP.NET has not attached to the session yet. That is intentional. If NeatUpload's processing was done after ASP.NET had attached to the session, the session would be locked for the entire time that the upload occurred. To workaround this, you can use NeatUpload's SimpleWebRemoting class which is what the SessionBasedUploadStateStoreProvider uses to maintain upload state in the session while the upload is occuring. SimpleWebRemoting.MakeRemoteCall() will make a request using the same cookies as the current request. Use it to call a handler that you write. In your handler, use SimpleWebRemoting.ProcessRemoteCallRequest() to handle the incoming request. If you want access to the uploaded files from your handler, then you should pass UploadModule.Files as a parameter in your remote call. Accessing UploadModule.Files from your handler won't work because the request to your handler isn't actually an upload request.
For an example of using the SimpleWebRemoting, see SessionBasedUploadStateStoreProvider.cs and UploadStateStoreHandler.cs.
Clear as mud? :-)
--Dean
|