Re: Why Doesn't This Work?

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Apr 18, 9:35 pm, bruce barker <nos...@xxxxxxxxxx> wrote:
could be caching, try:

Img.src = '/PersistSessionState.aspx?c=' + Count;

bruce (sqlwork.com)



Joey wrote:
I am working on an asp.net 1.1 web app in C#. I downloaded some sample
code that is supposed to allow for me to persist session state. The
code is as follows:

private void PersistSessionState()
{
int MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000;
string Script = @"
<script type='text/javascript'>
var Count=0;
var Max = 1000;
function PersistSessionState()
{
Count++;
if (Count<Max)
{
window.status = 'Link to server refreshed ' +
Count.toString()+' time(s)';
var Img = new Image(1,1);
Img.src = '/PersistSessionState.aspx';
}
}
window.setInterval('PersistSessionState()'," +
MilliSecondsTimeOut.ToString()+ @");
</script>
";

this.Page.RegisterClientScriptBlock("PersistSessionState", Script);
}

When I put this into my app, I did the following:

1. I added this function to the code behind page.
2. I added the line "this.PersistSessionState();" to call the function
from the Page_Load event handler.
3. I added "<%@ OutputCache Location='None' VaryByParam='None' %>" at
the top of the aspx page, to control the client-side caching.
4. I set the session timeout value to "1" in the web.config file.

Now, when I run this, (predictably) after about thirty seconds, the
status bar reads "Link to server refreshed 1 time(s)". As you can see
in the javascript code, this fires about thirty seconds before the
Session times out. So, when I see the message and wait about 45
seconds or so after, if I try to click another page on the site, I get
a "Server Error in '/' Application - Object reference no set to an
instance of an object" message. This happens because the solution did
not work - the session expired.

So what is wrong with this solution? Why doesn't it work? How can I
fix it?

Thanks in advance for your help.

JP- Hide quoted text -

- Show quoted text -

OR

Img.src = '/PersistSessionState.aspx?' + new Date().getTime()

also read this article about preload via js
http://www.webreference.com/programming/javascript/gr/column3/

or use XMLHTTP

var page_request = false;
page_request = new ActiveXObject('Msxml2.XMLHTTP');
page_request.open('GET', '/PersistSessionState.aspx?' + new
Date().getTime(), true);
page_request.send(null);

.



Relevant Pages

  • Re: HTA error in Windows Vista
    ... this file can be included in master HTA frames only!!! ... var strcomputer = "." ... it will just start another HTA subapp instead of calling ... it will at least fix the session ID ...
    (microsoft.public.inetsdk.programming.scripting.vbscript)
  • Re: [PHP] accessing one objects attribute from another
    ... am running into an odd thing that I can't figure out what a ... var $thisVar; ... There are a number of variables and methods that are common throughout ... stored in the object that is hanging around in the session. ...
    (php.general)
  • Re: [PHP] accessing one objects attribute from another
    ... am running into an odd thing that I can't figure out what a ... var $thisVar; ... There are a number of variables and methods that are common throughout ... stored in the object that is hanging around in the session. ...
    (php.general)
  • Re: Solution for the ASP Session Timeout Warning Problem
    ... > // The warning window pops up 1 minute before the session expires. ... > var jsTimeOut; ... > timeOutWarning)); ... case "renew": ...
    (microsoft.public.inetserver.asp.general)