1
Vote

Viewstate Loss while uploading images in fileUploadeder1_FileReceived event

description

I am using Filereceived event to save the files in byte array form in Viewstate.
 
Following is the code:
 
When i upload multiple images ViewState["ImageTable"] is always null during every upload. I dont know whats the problem. Please help.

file attachments

comments

Wind0 wrote Jun 20, 2011 at 8:21 PM

Same here with SessionState.

drdubbelklick wrote Sep 24, 2012 at 9:17 PM

Seen the same too. I logged sessionID and threadID of each incoming request, starting at global.asax.cs and up to the event handler catching the file information.
It seems that IsPostback is never set to true, indicating that the control always calls the page as if it was the first time, hence ViewState is reset. I tried saving the file information in Session variables instead, and then it worked. My image list then kept its value.
I have noticed something that is a bit worrying though: the flag isLast was set to true on the third call when I had selected four files and uploaded them.
When I did a lock() statement surrounding the entire event handler, the last file reported had its isLast flag set to true, i.e. there is a multithreading issue in the control.

wrote Feb 14, 2013 at 8:00 PM