Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

In my asp.net application, iam using windows forms.dll to use some of the windows controls by creating a thread.This works fine in my system but is giving a session timeout when hosted on IIS.
Creating a thread gives me session time out on IIS.
How do i create threads that can work fine on IIS?

Below is the code where iam created the thread.

C#
public string[] DisplayFileDialog()
        {
            string[] result = null;

            try
            {
                Thread objThread = new Thread(state =>{
                    result = FnOpenFileDialog();
                    // TODO: do something with the returned result
                });

                objThread.IsBackground = false;
                objThread.SetApartmentState(ApartmentState.STA);
                objThread.Start();
                objThread.Join();
                return result;

            }
            catch (Exception ex)
            {

              
                return result;
            }

     protected string[] FnOpenFileDialog()
        {
            IntPtr hdlr = GetForegroundWindow();

            WindowWrapper Mockwindow = new WindowWrapper(hdlr);

            OpenFileDialog fDialog = new OpenFileDialog();

            fDialog.Title = "Select Files";

            fDialog.Multiselect = true;
            fDialog.CheckFileExists = true;
            fDialog.CheckPathExists = true;

            System.Windows.Forms.DialogResult dr = fDialog.ShowDialog(Mockwindow);
            string[] filenames = fDialog.FileNames;
            return filenames;
        }


Thanks in advance.
Posted
Updated 4-Oct-12 3:23am
v3

Hi,

Try to set cookies in your browser and assign values from cookies to session.

Hope this will help you.
 
Share this answer
 
Hi ,


That was because my server is of 64 bit and windows forms handler window was of 32 bit.
I cannot use a windows forms object on the server.
I used flajaxian uploader to solve my problem.This allows me to select multiple files even in IE 7.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900