Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Web.config session timeout

Reply
Thread Tools

Web.config session timeout

 
 
steph_mw@hotmail.com
Guest
Posts: n/a
 
      02-21-2006
I have a web application and when a user opens the application (using
windows integration) and loads some data, it loads a ID number into the
session state. If for some reason they go away from their PC and come
back after 20 mintes they are receiving an error.

This error relates to the fact that the session has timed out and all
session variables have been cleared. The only issue I have with this is
that the session timeout is set to 24 hours (1440 minutes). I
understand that this is the maximum value.

<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="1440" />

We have no issue with the session variables been open this long as the
server has available memory.

Can anyone help me with this issue or point me in the right direction.

TIA
Stephen

 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      02-21-2006
Not sure why the session times out even if you set it to 1440 but i have a
good solution for you.

The idea is to send an aspx request to renew session every 10 minutes with
javascript code. So if user has browser open the session will never time
out. If browser closed session will timeout after 20 seconds.

See code below.

Step 1.
The code for renewSes.aspx.cs. You must not have any HTML in renew.aspx
file.

public class renewSes : System.Web.UI.Page

{

static byte [] gif =
{0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00 ,0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x09,0x00 ,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00 ,0x01,0x00,0x00,0x08,0x04,0x00,0x01,0x04,0x04,0x00 ,0x3b,0x00};

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

InitializeComponent();

base.OnInit(e);

}




private void InitializeComponent()

{

Response.AddHeader("ContentType", "image/gif");

Response.Cache.SetCacheability(HttpCacheability.No Cache);

Response.BinaryWrite(gif);

Response.End();

}

#endregion

}





Step2.

Each page must have following script in the beginning

<script language="Javascript">

window.setInterval("renewSession()", 600000);

function renewSession()

{

document.images("renewSession").src = /renewSes.aspx?par=" + Math.random();

}

</script>

Step3.

Each page must have somewhere in HTML

<IMG name="renewSession" height=1 src="/images/transparentpixal.gif" width=1
border=0>

You can grab transparentpixal.gif from
http://www.cardone.com/English/Club/...arentpixal.gif

-------------------------------------------------------------------------------------------------------------

For step2 and step 3 I usually create UserControl that does in a code in
Init method

Page.RegisterClientScriptBlock("renewSession", "<script
language=\"Javascript\">\r\n" +

"window.setInterval(\"renewSession();\", 600000);\r\n" +

"function renewSession()\r\n" +

"{document.images(\"renewSession\").src = \"/renewSes.aspx?par=\" +
Math.random();}\r\n" +

"</script>\r\n");

And HTML has that line with <IMG tag>

Then all you need to do is to drop that control on each page in your
project.

George.



<> wrote in message
news: ups.com...
>I have a web application and when a user opens the application (using
> windows integration) and loads some data, it loads a ID number into the
> session state. If for some reason they go away from their PC and come
> back after 20 mintes they are receiving an error.
>
> This error relates to the fact that the session has timed out and all
> session variables have been cleared. The only issue I have with this is
> that the session timeout is set to 24 hours (1440 minutes). I
> understand that this is the maximum value.
>
> <sessionState mode="InProc"
> stateConnectionString="tcpip=127.0.0.1:42424"
> sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
> cookieless="false"
> timeout="1440" />
>
> We have no issue with the session variables been open this long as the
> server has available memory.
>
> Can anyone help me with this issue or point me in the right direction.
>
> TIA
> Stephen
>



 
Reply With Quote
 
 
 
 
steph_mw@hotmail.com
Guest
Posts: n/a
 
      02-21-2006
Thanks George for your solution.

However I would like to know why it still times out when the timeout
value is stored in the web.config file. If anyone can shed some light
on this it'd be appreciated.

Thanks
Stephen

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      02-21-2006
Do not really know answer to your question.
May be you set to high. May be it can not be more than couple hours and
resets itself to default if you try to set it to high.

Try to set it to 60 and see if it's still going to timeout after 20 minutes.

-------------------------------------------------------------------------

but theoretically you should never change it. Just forget that it's even
possible


George.


<> wrote in message
news: ups.com...
> Thanks George for your solution.
>
> However I would like to know why it still times out when the timeout
> value is stored in the web.config file. If anyone can shed some light
> on this it'd be appreciated.
>
> Thanks
> Stephen
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= ASP .Net 4 04-11-2007 04:52 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM
Re: ASPX Page Timeout - Session Timeout bruce barker ASP .Net 2 07-20-2004 08:39 PM
Session contents lost despite Session.Timeout = 3000; and <sessionState mode="InProc" cookieless="false" timeout="300"> Carpe Diem ASP .Net 3 02-23-2004 07:10 PM
web.config session timeout and forms authentication timeout Do ASP .Net 2 11-23-2003 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57