Delay on logout

  • Thread starter Michael D. Jones
  • 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
 
M

Matt Berther

Hello Michael,

This will need to happen client side...

Write out some javascript (using Page.RegisterStartupScript) that uses window.setTimeout
and top.location.href.
 
F

Fabio

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().
 
M

Michael D. Jones

Thanks, Matt

This works!

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

Michael
 
M

Michael D. Jones

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
 

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

Top