Click here to Skip to main content
15,792,397 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Expert,

I am Uday Satardekar,

In my web.config file i set session timeout like following

<sessionState timeout="120"

but many times after 10-15 mins session expired automatically.

some times it working fines for me.
I observed this problem in every browser.

i set following configuration in web.config file.

<machineKey validationKey="7F962D9FAC5BA3E79A71E722B0FD79BAF52618501DABB750004795CFFDF1AC6BD66BA5FF028DE94730C2FBA150C8A049CC7B35B2CE4CC60BEF0AE47B36CBA5DF" decryptionKey="F6572AF020B96CB22ED4B987E2C0DB0DA6E68493A7F07C6F37F574907F91FDA6" validation="SHA1" decryption="AES"/>
  <trace enabled="false" pageOutput="false" requestLimit="15" mostRecent="false"/>

<compilation debug="true">

<validation validateIntegratedModeConfiguration="false"/>

      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00"/>

Above are some imp sestting in web.config file.

please help me to sort out this problem.

Thanks in advance.........................

1 solution

Hi, use below JS code:

<script language="javascript" type="text/javascript">
        var sessionTimeoutWarning = 1;
        var sessionTimeout = '<%= Session.Timeout %>';
        var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000;
        //        setTimeout('SessionWarning()', sTimeout);
        setTimeout('SessionWarning()', sessionTimeout);
        function SessionWarning() {
            var img = new Image(1, 1);
            img.src = '<%= System.Configuration.ConfigurationSettings.AppSettings["SitePath"].ToString()%>/KeepAlive.aspx?date=' + escape(new Date());
//            var message = "Your session will expire in another " +
//	(parseInt(sessionTimeout) - parseInt(sessionTimeoutWarning)) +
//	" mins! Please Save the data before the session expires";
//            alert(message);

make a new page KeepAlive.aspx. it is a blank page.

Don't forget to mark, if it is your solution. :-)
Share this answer
udusat13 21-Feb-12 7:45am    

img.src = '<%= System.Configuration.ConfigurationSettings.AppSettings["SitePath"].ToString()%>

above line shows null reference
i have created Keepalive.aspx page..

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