This is a migrated thread and some comments may be shown as answers.

Performing postback "pings" while uploading

5 Answers 172 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Martin Kutter
Top achievements
Rank 1
Martin Kutter asked on 08 Jan 2009, 01:11 PM
Hi,

This is for RadControls for ASP.NET Q2 2008.

Here is the situation:
A user logs in to the system and uploads a file for some processing. The session timeout is of 20 min and we cannot guarantee that the user will have a fast internet connection. If the file is big (like 40 MB), it will take more time to upload than the session timeout. This will result in the user being kicked out when the upload completes and the button event handler tries to execute.

So, to remedy this, I have added a RadAjaxPanel and a RadAjaxTimer inside of it in order to send dummy postbacks (pings) to keep the session alive. I have added javascript code to start the timer when the user clicks on the upload button. The tick event handler is called once, then the upload begins and the progress bar starts. During the upload, my timer doesn't tick anymore (or maybe it ticks but no event handler is executed). So basically I am not able to make a call to the web site while the upload is in progress.

I need to know if there is a way to make regular asynchronous postbacks to my page in order to keep the session alive and avoid timeouts for long uploads.

Thank you.



5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Jan 2009, 05:49 PM
Hello Martin Kutter,

As far as I know script execution stops when the browser starts submitting a file. Unfortunately I don't know of any way to ping the server while this happens.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Martin Kutter
Top achievements
Rank 1
answered on 12 Feb 2009, 01:31 PM
OK, I have now changed the design of the process and I would like to make a javascript call before the upload starts. In fact, the javascript call will check if the user is still logged or not via page methods (AJAX).
What I need now is a way to stop the upload in case the method returns that the user is not logged in anymore. Is there an event that is fired when the upload starts? in this case, maybe in the event handler I can make the server call and decide whether or not to proceed with the upload.

Thanks.
0
Genady Sergeev
Telerik team
answered on 13 Feb 2009, 03:05 PM
Hello Martin Kutter,

For such a cases, the RadProgressManager provides OnClientSubmitting event which you can handle in order to cancel the upload. You can refer to this article for more detailed explanation.

For your convenience, I have attached a sample project illustrating it.

Let me know whether this helps or if I can assist you further.

Kind regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Martin Kutter
Top achievements
Rank 1
answered on 16 Feb 2009, 09:20 AM
Thank you for your reply.

I have checked the code you have sent. I cannot use it as it is since I am using web service call from javascript. I cannot implement something like "checkStatus" method because I am using RadAjaxServiceManager and so the return result of the call of the webservice is given by an other callback method. So what I have is this:

var contOK = true;

function CallService()
{
    SessionManager.CheckSession('1', sessionID, ServiceCompleteCallback,ServiceErrorCallback);
}

function ServiceCompleteCallback(ResponseAsJSON, ResponseAsXml, ResponseAsText)
{
    if (ResponseAsJSON==false)
    {
        contOK=false;
    }
}

function validateSubmission(source, eventArgs)
{
    CallService();
    if (contOK==false)
    {
        eventArgs.set_cancel(true);
    }
}

The problem with this code is that it is async call, so the function validateSubmission executes and finishes before the result of CallService is returns, and so contOK is never false.

Also, the validateSubmission method is called on every postback and I would prefer avoiding such a scenario.

Any idea on how i can make this work?

Thanks
0
Genady Sergeev
Telerik team
answered on 18 Feb 2009, 02:10 PM
Hello Martin Kutter

Have you tried to repeatedly call the validateSubmission function via window.setInterval? To be honest, I can't get a full idea of your scenario. I will appreciate if  you could prepare sample running project describing it.

Kind regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Upload (Obsolete)
Asked by
Martin Kutter
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Martin Kutter
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or