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
>