Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to automatically end/logout a session?

Posted on 2004-04-30
4
Medium Priority
?
626 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
esteban_felipe earned 380 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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