Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 September 25th, 2007, 11:25 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default TIP: Redirecting when session expires

Caught the following idea while looking for something else and thought i'd share it here.

Bascally, when a session expires, it's good practice to redirect to a 'safe' page that let's the user know that both the seesion has expired AND that any personal info is not on display.

to this end, the following can be added to the template.master.cs file:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            HttpContext.Current.Response.AppendHeader("Refresh ",
                Convert.ToString(((HttpContext.Current.Session.Tim eout * 60) - 5))
                + "; Url=default.aspx?timeout=true");

        }

obviously, the value Url=default.aspx?timeout=true would be that of an informational page or (as i've done) a parameter added onto the default.aspx page that when opened diplays the 'information' panel.

just so you know :)

also, the more discerning among you will twig to the idea that the same kind of logic (appending a response header) could be applied to the AddEditPost.aspx form to redirect to the 'urlreferer' after 5 seconds or so once a post has been added/amended!!

jimi

http://www.originaltalent.com
__________________
jimi

http://www.originaltalent.com
 
Old October 25th, 2007, 12:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cool idea. Now for the hard part: how can we alert the user a minute before the session expires and allow him to click to keep the session alive? I've seen that done on some sites but I have never done it myself.

Eric

 
Old October 25th, 2007, 12:53 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

That sounds as if there's either a windows service or a web service "pushing" an event to the client... Do you have any idea what site it was? I'd like to see that in action, just to have a peek :)

http://entropia-online.blogspot.com/
 
Old October 25th, 2007, 04:07 AM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the session expire after the user spend some time idle from the site right?

So... If he is idle, he probably doesn't read any alert!!

But if you really want to do that, you can use javascript. Everytime you make one request you reset the counter, and when the Timecounter reach the timeSessionminutes - 1 then display the alert.
 
Old November 16th, 2007, 01:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

We have users who have our web app running most of the day. Sometimes they switch windows to work in Excel, Word, Outlooks, etc, but the web app is still open in the background. I want to pop up a new window over the top of whatever they're doing to give them a chance to keep their session alive. Maybe the JavaScript can go in the master page? JavaScript is one of my weaknesses, I'm afraid.

Eric

 
Old November 16th, 2007, 05:42 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great idea man... I love it :)

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session variable expires early BananaJim Classic ASP Professional 0 May 14th, 2007 05:58 AM
Session expires immediately codebuyer Classic ASP Components 6 March 18th, 2005 12:54 PM
Session expires imediately on logging in codebuyer Classic ASP Professional 3 February 24th, 2005 02:37 AM
deleting files as session expires jaisonkmathews General .NET 4 October 18th, 2004 12:07 AM





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