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 PersistSessionS tate()
{
int MilliSecondsTim eOut = (this.Session.T imeout * 60000) - 30000;
string Script = @"
<script type='text/javascript'>
var Count=0;
var Max = 1000;
function PersistSessionS tate()
{
Count++;
if (Count<Max)
{
window.status = 'Link to server refreshed ' +
Count.toString( )+' time(s)';
var Img = new Image(1,1);
Img.src = '/PersistSessionS tate.aspx';
}
}
window.setInter val('PersistSes sionState()'," +
MilliSecondsTim eOut.ToString() + @");
</script>
";
this.Page.Regis terClientScript Block("PersistS essionState", 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.PersistSe ssionState();" to call the function
from the Page_Load event handler.
3. I added "<%@ OutputCache Location='None' VaryByParam='No ne' %>" 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 3 2721
could be caching, try:
Img.src = '/PersistSessionS tate.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 PersistSessionS tate()
{
int MilliSecondsTim eOut = (this.Session.T imeout * 60000) - 30000;
string Script = @"
<script type='text/javascript'>
var Count=0;
var Max = 1000;
function PersistSessionS tate()
{
Count++;
if (Count<Max)
{
window.status = 'Link to server refreshed ' +
Count.toString( )+' time(s)';
var Img = new Image(1,1);
Img.src = '/PersistSessionS tate.aspx';
}
}
window.setInter val('PersistSes sionState()'," +
MilliSecondsTim eOut.ToString() + @");
</script>
";
this.Page.Regis terClientScript Block("PersistS essionState", 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.PersistSe ssionState();" to call the function
from the Page_Load event handler.
3. I added "<%@ OutputCache Location='None' VaryByParam='No ne' %>" 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
It appears MilliSecondsTim eOut is the object not set to instance - there
doesn't seem to be any declaration for the object (in the script block), and
you are attempting to access a "ToString() " method at the end of the script.
"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 PersistSessionS tate()
{
int MilliSecondsTim eOut = (this.Session.T imeout * 60000) - 30000;
string Script = @"
<script type='text/javascript'>
var Count=0;
var Max = 1000;
function PersistSessionS tate()
{
Count++;
if (Count<Max)
{
window.status = 'Link to server refreshed ' +
Count.toString( )+' time(s)';
var Img = new Image(1,1);
Img.src = '/PersistSessionS tate.aspx';
}
}
window.setInter val('PersistSes sionState()'," +
MilliSecondsTim eOut.ToString() + @");
</script>
";
this.Page.Regis terClientScript Block("PersistS essionState", 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.PersistSe ssionState();" to call the function
from the Page_Load event handler.
3. I added "<%@ OutputCache Location='None' VaryByParam='No ne' %>" 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
On Apr 18, 9:35 pm, bruce barker <nos...@nospam. comwrote:
could be caching, try:
Img.src = '/PersistSessionS tate.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 PersistSessionS tate()
{
int MilliSecondsTim eOut = (this.Session.T imeout * 60000) - 30000;
string Script = @"
<script type='text/javascript'>
var Count=0;
var Max = 1000;
function PersistSessionS tate()
{
Count++;
if (Count<Max)
{
window.status = 'Link to server refreshed ' +
Count.toString( )+' time(s)';
var Img = new Image(1,1);
Img.src = '/PersistSessionS tate.aspx';
}
}
window.setInter val('PersistSes sionState()'," +
MilliSecondsTim eOut.ToString() + @");
</script>
";
this.Page.Regis terClientScript Block("PersistS essionState", 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.PersistSe ssionState();" to call the function
from the Page_Load event handler.
3. I added "<%@ OutputCache Location='None' VaryByParam='No ne' %>" 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 = '/PersistSessionS tate.aspx?' + new Date().getTime( )
also read this article about preload via js http://www.webreference.com/programm...pt/gr/column3/
or use XMLHTTP
var page_request = false;
page_request = new ActiveXObject(' Msxml2.XMLHTTP' );
page_request.op en('GET', '/PersistSessionS tate.aspx?' + new
Date().getTime( ), true);
page_request.se nd(null); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: AnnMarie |
last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it
works fine in IE.
I made some of the suggested changes which enabled it to work in IE.
I couldn't make all the changes because then it didn't work in IE.
How can I enable this javascipt form validation to work in Netscape?
When I use netscape, none of the alert boxes...
|
by: Mark Johnson |
last post by:
It doesn't seem possible. But would the following also seem a
violation of the general notions behind css?
You have a DIV, say asociated with class, 'topdiv'.
Inside of that you have an anchor (and whatever it contains),
associated with class, 'a'.
Somewhere else in, 'topdiv', there is a span or element (containing
whatever),...
|
by: Matt |
last post by:
I want to know if readOnly attribute doesn't work for drop down list?
If I try disabled attribute, it works fine for drop down list. When I
try text box, it works fine for both disabled and readOnly attribute.
For example, #1 will work, but #2 doesn't work
1) <SELECT name="streetDirection" class="FormInput" DISABLED>
In JavaScript, I have...
|
by: Christopher Benson-Manica |
last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.)
strchr() is to strrchr() as strstr() is to strrstr(), but strrstr()
isn't part of the standard. Why not?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
|
by: A.M-SG |
last post by:
Hi,
I have an aspx page at the web server that provides PDF documents for smart
client applications.
Here is the code in aspx page that defines content type:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" +
fileID.ToString() + ".pdf");
| |
by: bbp |
last post by:
Hello,
In an ASPX page I have a "Quit" button which make a simple redirect in
code-behind.
This button doesn't work no more since (I think) I moved from the framework
1.0 to 1.1
and it doesn't work only on IE! My ASPX page works in FireFox.
If the button doesn't work it's because of validators (and it worked with
the same code in v1.0).
|
by: Dave Moore |
last post by:
Hi All,
Ok, here's my problem. I want to open a file and process its contents.
However, because it is possible that the file may not exist, I also want to
check whether the file() function is successful before attempting to process
any returned data from the file() function. The php file() manual page
suggests that it returns FALSE if it is...
|
by: Sourcerer |
last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We both
have Windows XP Professional. I have .NET framework 2.0, and he had 1.0 and it
didn't work; then he installed 2.0 and it still didn't work; so he tried with
2.1 and it didn't work, then 3.0...
|
by: Johnny Jörgensen |
last post by:
I've got a usercontrol derived from a normal ComboBox that contains some
special formatting code. On my main form I've got a lot of my custom
comboboxes.
I discovered a bug in the derived control and fixed it. But it still doesn't
work for the controls already added to the form. It works fine for new
instances of the control dragged from...
|
by: alex |
last post by:
I've converted a latin1 database I have to utf8. The process has been:
# mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore
--skip-set-charset mydb mydb.sql
# iconv -f ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql
mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |