Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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 April 16th, 2009, 05:50 AM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default Redirecting to a different page during session expiration

I am using forms authentication and whenever a session expires, it is automatically redirected to the loginurl.

Is there a way for me to redirect session timeouts to a different page and only unauthenticated requests to the loginurl?
__________________
\"Dont you ever give up!\"
 
Old April 16th, 2009, 02:04 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Quote:
Originally Posted by aldwinenriquez View Post
I am using forms authentication and whenever a session expires, it is automatically redirected to the loginurl.

Is there a way for me to redirect session timeouts to a different page and only unauthenticated requests to the loginurl?

I'm sure there is. I'm not sure I understand the question or maybe don't have enough information. If your code is redirecting on session timeout, why not just point it to another page in that place, instead of to the login page?

Not sure I really understand the problem.

Richard
 
Old April 16th, 2009, 08:52 PM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

Which event is for the session timeout.
I tried using Session_End event implemented in an HttpModule and used Response.Redirect("SomePage") but never worked.

or, where should i put the redirection code?
__________________
\"Dont you ever give up!\"
 
Old April 16th, 2009, 09:58 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

On my login page I assign a Session variable to the user.

Something like Session("UserID")

In the include file for the menu header on every page I have this code:

If Len(Session("UserID")) = 0 Then
Response.Redirect("/logout.asp")
End If

If their session has timed out then the length of that session variable will be 0. In this case I redirect to a logout page and run this code just to make sure everything is cleared out.

Session.Contents.RemoveAll()
Session.Abandon()
Response.Redirect("/default.asp?url=" & Server.UrlEncode(Request("URL")))

which redirects back to the login page.

You could do somewhat the same thing and redirect timed out sessions anywhere you want.

Richard





Similar Threads
Thread Thread Starter Forum Replies Last Post
TIP: Redirecting when session expires jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 November 16th, 2007 05:42 AM
Redirecting Page With Alert arnabghosh Classic ASP Professional 0 November 8th, 2007 02:43 AM
Session expiration manoj_k79 Classic ASP Basics 1 October 13th, 2006 07:19 AM
Page Redirecting venkatagiri ASP.NET 2.0 Basics 0 June 22nd, 2006 06:17 AM
Page Expiration? Thagi ASP.NET 1.x and 2.0 Application Design 2 March 7th, 2006 12:12 AM





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