Solved

How to automatically end/logout a session?

Posted on 2004-04-30
4
592 Views
Last Modified: 2010-08-05
How to automatically end a session?
In idea, I have set up in web.config that after 20 minutes of no user action, my ASP NET application will call Logout.aspx and then logout automatically without showing any error aspx page.

In web.config:
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>

In Global.asax.vb:
Private Sub Session_OnEnd(ByVal sender As Object, ByVal e As EventArgs)
        Server.Transfer("Logout.aspx", True)
End Sub

In Logout.aspx:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Server.CreateObject("Session.Management").SessionEnd()
End Sub

But I'm not sure if after 20 minutes of no user action, Logout.aspx will be called. And the statement Server.CreateObject("Session.Management").SessionEnd() gets error!
What would be the correct way of ending session? Thanks!
0
Comment
Question by:IloveClipper
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
esteban_felipe earned 95 total points
ID: 10965416
Hi IloveClipper,

Your code will actually end the session but the Server.Transfer("Logout.aspx",true) won't work. That's because you can't push pages to the client using server side code if the client haven't first requested a page. The correct way to achieve what you're looking for will be a client side javascript that will redirect to another page (logout.aspx in your case) 20 minutes after the current page was rendered.

Esteban Felipe
www.estebanf.com
0
 

Author Comment

by:IloveClipper
ID: 10965529
Esteban,
Does it mean that I have to put that javascript code on every aspx page of my project?
0
 
LVL 12

Expert Comment

by:esteban_felipe
ID: 10965934
you could use a base Page class that register the javascript
0
 

Expert Comment

by:venkat_parupudi
ID: 11150065
cfdsfsdfsdfsdfsd
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now