Re: Error occurring when Forms Authentication has timed out

  •  09-22-2010, 8:43 PM

    Re: Error occurring when Forms Authentication has timed out

    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.
    1. var timeoutPeriod = 1;   
    2.         function refreshPage() {               
    3.             var decRound = Math.round(Math.random() * 1000);   
    4.             var imgRefresh = new Image(1, 1);   
    5.             imgRefresh.src = 'Keepalive.aspx?id=' + decRound.toString();   
    6.             timeoutWarning = setTimeout(refreshPage, timeoutPeriod * 30000);   
    7.         }  
    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:
    1. <%@ 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.
     
    For the full article and reference for this post see http://www.codeproject.com/KB/aspnet/keepalive.aspx.
     
    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.
View Complete Thread