After transfering binary data(Image) Asynchronously to a page the page hangs

After transfering binary data(Image) Asynchronously to a page the page hangs

  

HI,

I have a .NET user control which I use to get biometric data and biometric identification of NeuroTechnology on a page.  That part works great. 

What am I trying to accomplish is to take the image taken by the usercontrol and send it to the server to be saved. I'm using the following code to accomplish this in the user control:


public static string UploadDataInBackground(string address, byte[] data)
        {
            WebClient client = new WebClient();
            Uri uri = new Uri(address);

            client.UploadDataCompleted += new UploadDataCompletedEventHandler(UploadDataCallback2);
            // Specify a progress notification handler.
            //client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
            client.UploadDataAsync(uri, "POST", data);

            return "Background photo transfer started.";
        }


 private static void UploadDataCallback2(Object sender, UploadDataCompletedEventArgs e)
        {
            string text = null;
            try
            {
                string reply = System.Text.Encoding.UTF8.GetString(e.Result);
                MessageBox.Show(reply);
                if(e.Cancelled)
                {
                    string result = "image upload Cancelled.";
                    MessageBox.Show(result, text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (e.Error != null)
                {
                    string error = e.Error.Message;
                    MessageBox.Show("error: " + error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("uploadDataCallback error: " + ex.Message, text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

The transfer starts ,  because in servicecenter I can see that the page is being called under monitoring -> webrequest , I see the page I'm calling with a duration.

at some point the browser shows a second page ( completely black) and it hangs the whole browser and other tabs.

At the page receiving the binary transfer I have in the preparation the following Actions:

I have the espace in debug with a breakpoint at the start of the preparation to check if it is being triggered and it is not.


Furthermore,even as I wait on the page and leave it hanged for a long period, the UploadDataCallback2
 is not being triggered, it is like the request stays there and does not send like a notification that it is done, or whatever. 

I have implemented this function also ( in the code Above I have it commented out) :

private static void UploadProgressCallback(Object sender, UploadProgressChangedEventArgs e)
        {
            string reply = e.BytesSent.ToString();
            MessageBox.Show(reply);
        }

When I put it back in the code, I get a lot of dialogboxes, that shows the bytes that have been sent, so this implies that the binary is being sent. but it is like it does not get a notification that the transfer was completed. 

Does anyone have some advice and or  knowledge what can be the cause that it hangs?

Thanks in advance.


Alexei 


Hi Alexei,

Server-side controls are not supported.

I recommend that you check for a client-side (javascript based control) which would be much easier to integrate with the platform and then use platform server actions to transfer the data to the server.

Joao Neves,  thanks for your reply

It is a .net User base control that runs through an activeX component in the browser on a client side. I'm using Javascript to call the functions of this control.  maybe It wasn't clear in my post above, 

The transfer through the HTTP post takes place asynchronously, but its like the transfer never get a notification that it finished.

obrigado,


Alexei