Timing function

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi all,

Ok, when I log out of my application I am going to redirect to a new page, called logout.aspx. This page is responsible for deleting session variable and resetting all other variables. Now I would like to add in a function that 10 second after the page loads the user automatically get redirected to another page, in this case say google.com.

Now this is what I was thinking of doing...
1. Loading my page as normal but in the page load() method calling a function called page_Redirect.
2. In the page_Redirect method, I will declare a variable x and let it equal to the current time. I also have a boolean variable which is currently equals to false.
3. I have a while loop that does the following (this is only pseudo code):
Code:
dim result as boolean = false
while result = false
   if time = (x+10sec) then
      result = true
      Response.redirect("www.google.com")
   end if 
end while

Am I approaching the problem the correct way, or is their a simplier way to do what i want to do.

Mike55
 
HJB417 said:
I would use the FormsAuthentication class for login/logout and use either javascript or insert a html meta refresh tag to do the delayed redirect.

Thanks for the reply. Why would you use the FormAuthentication class for logout? Can understand it for the login, and have used it in other projects for the log in.

Mike55
 
Mike55,

I used the following tag to do the same thing:

<head>
<META HTTP-EQUIV="refresh" content="3;URL=http://www.google.com">
</head>

number "3" specifies the time in seconds before redirecting.
 
Using code like this is an awful practice. It can and will annoy the user and mess up the flow of history in the browser. In other words, it will render the back button useless for some less-adept users. Either redirect to a page on the server (which sends a 30[0-4] response code) or don't do it at all.
 
Back
Top