Set session variables in upload_FileReceived

Jan 7, 2009 at 10:55 PM
Have anyone tried to set Session variables in function "upload_FileReceived" and retrieve these session variables for later processing. What I am trying to do is to save a list of file names (the uploaded files) in a session variable and then later retrieve them in another function/page. Below is the sample code I used.

        /// <summary>
        /// Handles the FileReceived event of the upload control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SharpPieces.Web.Controls.UploadEventArgs"/>
        /// instance containing the event data.</param>
        protected void upload_FileReceived(object sender, UploadEventArgs e)
        {
            if (e.File != null)
            {
                string savePath = Server.MapPath("App_Temp");
                string moviesPath = Server.MapPath("Movies_Dir");
                // Due to security issues, the save action itself is blocked in this demo.
                e.File.SaveAs(savePath + "\\" + "TEST" + e.File.FileName);

                if (Session["FILENAMES"] != null)
                {
                    ArrayList fileList = (ArrayList)Session["FILENAMES"];
                    fileList.Add(e.File.FileName.ToString());

                    Session["FILENAMES"] = fileList;
                }
                else
                {
                    ArrayList fileList = new ArrayList();
                    fileList.Add(e.File.FileName.ToString());
                    Session["FILENAMES"] = fileList;
                }               
            }
        }

Session variable "FILENAMES" will be retrieved later on by other functions. This works in IE7, but Firefox doesn't. I kept getting null value for variable "FILENAMES". Does anybody know how to solve this problem?

Thank you in advance!
Johnny