How to kill a web page?

S

Steve Kershaw

Hi,

I have an ASP.Net web page that has a timer that needs to be killed
when the timer fires off. How can I do this from the master.page?

Thanks
Steve
 
G

George Ter-Saakov

Kill is a bad word :)
My guess you want to log user out after some timeout?

Simply have your master.page to output following JavaScript

<script>
function TimeOut()
{
window.location="/logout.aspx"
}
window.setTimeout("TimeOut();", 15 minutes);

See help on setTimeout function in Javascript (not in .NET).

<script>
George.
 
M

Mark Rae


Change this to:

window.setTimeout("TimeOut();", 15 minutes);

This will throw an exception because the second argument of the
window.setTimeout method requires an integer value denoting the number of
milliseconds to delay:

window.setTimeout("TimeOut();", 900000);
 
S

Steve Kershaw

Change this to:



This will throw an exception because the second argument of the
window.setTimeout method requires an integer value denoting the number of
milliseconds to delay:

window.setTimeout("TimeOut();", 900000);

Is there anyway to logout someone or drop the Web Page in C#???
Steve
 
S

Steve Kershaw

Change this to:



This will throw an exception because the second argument of the
window.setTimeout method requires an integer value denoting the number of
milliseconds to delay:

window.setTimeout("TimeOut();", 900000);

That worked! But I can still click the back button and return to the
previous page which is a problem here!!! If the timeout happends then
the current page must either be "killed" or the new page must not have
any reference BACK to the old page!

Thanks again for your help.

Steve
 
M

Mark Rae

That worked! But I can still click the back button and return to the
previous page which is a problem here!!! If the timeout happends then
the current page must either be "killed" or the new page must not have
any reference BACK to the old page!

Despite what some people will tell, there is really no 100% reliable way of
disabling the back button...
 
G

George Ter-Saakov

You can add following code to your every page
Response.CacheControl = "no-cache";

Response.Expires = -1;

Theoretically that prevents caching and if user clicks back button browser
forced to send a request to the server (which in turn should redirect user
to login page if Session has expired)

worked for me although I did not do extensive testing with all browsers that
out there.

George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top