Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2006, 01:59 PM
Authorized User
 
Join Date: Apr 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET Session End Redirect

Hi,
I have tried to automatically redirect by application to return back to my login page when session end by putting a redirect code in global session_end method, but it does not redirect even though the method was called. How would I redirect to another page automatically when session expired?

Thank you,
Peter

Peter
__________________
Peter
 
Old February 24th, 2006, 02:44 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can't. Period.

SessionEnd is never associated with a request; it fires at the server without a browser / client context. There is no way to redirect a client from the End event, because there is no client.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 24th, 2006, 02:51 PM
Authorized User
 
Join Date: Apr 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So, there is no other way except using timer or JavaScript which is not neccesary synchronize with SESSION state?

Peter
 
Old February 25th, 2006, 05:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If you want to redirect to Login.aspx when the session has expired, can't you just always redirect to the Login page when the user hasn't logged in?

In addition to that, you can set a cookie that the user has previously logged in and use that cookie to determine where to redirect when they start a new session.

HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 27th, 2006, 03:31 PM
Authorized User
 
Join Date: Apr 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, you are correct if you use cookie as you mention or check for session count in Global Global_AcquireRequestState event. Nonetheless, this require user intervention. In another word, when the session or cookie expired, the page doesn't redirect until user refresh the page or do something to the page. What I would like is the page to expire or redirect automatically without any user action. I was able to redirect by using javascript.

Peter
 
Old February 27th, 2006, 04:55 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

True. But to make it even simpler, you can add an HTML <meta> refresh tag to the page. If you set the refresh period to just under or over your session timeout (depending on whether you want to keep the session alive, or want to redirect to the Login page directly after a session timeout) the browser automatically takes the user to the requested page after a certain amount of time.

I think the "Thank you for your contribution" page that I am about to see when I click Post New Reply in a few seconds uses that technique....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 27th, 2006, 04:57 PM
Authorized User
 
Join Date: Apr 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Good point. Thanks Imar for your input.

Peter
 
Old February 27th, 2006, 05:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
redirect querystring with session value alxtech Classic ASP Professional 1 July 16th, 2007 07:06 AM
dll updation causes session to end madhukp ASP.NET 1.0 and 1.1 Basics 4 February 18th, 2006 10:26 PM
ASP Session End xergic Classic ASP Components 13 May 3rd, 2005 01:48 AM
end session notification jess VB.NET 2002/2003 Basics 1 February 22nd, 2005 02:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.