Delay on logout

  • Thread starter Thread starter Michael D. Jones
  • Start date Start date
M

Michael D. Jones

Hi all,

I would like to have a delay on a logout page. Here is what I have so far:

logout.aspx
-----------
Page_Load()

FormsAuthentication.SignOut();
Thread.Sleep(5000);
Response.Redirect("homepage.aspx");

What I would like the code to do is, display the logout.aspx page, then wait
5 seconds, then redirect the user to another page.

However, the trouble I'm having is that since I have the delay in the
Page_Load(), the page does not load for 5 seconds, then without displaying,
it redirects to the homepage.aspx.

Any ideas?

Thanks,
Michael
 
Hello Michael,

This will need to happen client side...

Write out some javascript (using Page.RegisterStartupScript) that uses window.setTimeout
and top.location.href.
 
Michael said:
Hi all,

I would like to have a delay on a logout page. Here is what I have so far:

logout.aspx
-----------
Page_Load()

FormsAuthentication.SignOut();
Thread.Sleep(5000);
Response.Redirect("homepage.aspx");

Try to move Thread.Sleep(5000); to Page_Unload().
 
Thanks, Matt

This works!

<script language="javascript">
function RedirectPage(oSrc,args) {
window.location='http://www.domain.com';
}
</script>
onload="setTimeout('RedirectPage()',5000)"

Michael
 
Thanks, Fabio

I appreciate your suggestion.

Michael

Fabio said:
Michael said:
Hi all,

I would like to have a delay on a logout page. Here is what I have so
far:

logout.aspx
-----------
Page_Load()

FormsAuthentication.SignOut();
Thread.Sleep(5000);
Response.Redirect("homepage.aspx");

Try to move Thread.Sleep(5000); to Page_Unload().

--
Software is like sex: it's better when it's free -- [Linus Torvalds]

Fabio Marini - A+, RHCT, MCDBA, MCAD.NET
To reply: news [at] mamakin1976 [dot] plus [dot] com
 
Back
Top