Hi everyone,
For anyone who does not wish to have the user logged out at all during a file upload you can use a script similar to below.
-
var timeoutPeriod = 1;
-
function refreshPage() {
-
var decRound = Math.round(Math.random() * 1000);
-
var imgRefresh = new Image(1, 1);
-
imgRefresh.src = 'Keepalive.aspx?id=' + decRound.toString();
-
timeoutWarning = setTimeout(refreshPage, timeoutPeriod * 30000);
-
}
Put that into a script block in your upload page. There are many different ways to use this script, the basic principle remains the same. Firstly you need to create an empty aspx. I have called mine Keepalive.aspx. In this page you need to put the following:
- <%@ OutputCache Location="None" VaryByParam="None" %>
This will tell the browser basically not to cache the page so it must reload it each time. and thats it for the Keepalive page. When the Image requests the Keepalive.aspx page, a request is sent to the server, and your forms authentication ticket is refreshed without changing anything in the broswer (I use this inside an UpdatePanel but I'm not sure how it works outside of one).
Some things to note is the variable timeoutPeriod is set to 1, this equates to 30 seconds as set by setTimeout(refreshPage, timeoutPeriod * 30000), : 1ms * 30000 = 30000ms = 30s. So the timout refresh will be done every 30 seconds. To call this code you can either place a call to it within the body onload event, or alternately when you upload a file to the server.
I successfully use this technique with CuteSoft AJAX uploader.
My settings are below:
IIS 7.0, ASP.Net 3.5, AJAX Uploader PersistedFileUpload, Manual Upload, Inside an update panel.