473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Session.Abandon

I have an <asp:LinkButton runat="server" id="btnLogin"/> control that I use
in my page header for login/logout link. Depending on the session state
when the page loads, I set the .Text and .PostBackUrl properties, like so...

Private Sub Page_Load(...)
If CType(Session("started"), Boolean) = False Then
WriteLogin()
Else
WriteLogout()
End If
End Sub

Private Sub WriteLogin()
btnLogin.Text = "LOGIN"
btnLogin.PostBackUrl = "../login.aspx"
End Sub

Private Sub WriteLogout()
btnLogin.Text = "LOGOUT"
End Sub

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
If CType(sender, System.Web.UI.WebControls.LinkButton).Text = "LOGOUT"
Then
Session.Abandon()
WriteLogout()
End If
End Sub

The problem I'm having is, I have to click on 'LOGOUT' twice to work. I'm
thinking the Session.Abandon statement doesn't really work until the page
finishes processing and the content is flushed to the client. That confused
me, though, because the btnLogin.Text still says 'LOGOUT' after the first
click. What is happening here?
Nov 18 '05 #1
1 2571
Random wrote:
I have an <asp:LinkButton runat="server" id="btnLogin"/> control that I use
in my page header for login/logout link. Depending on the session state
when the page loads, I set the .Text and .PostBackUrl properties, like so...

Private Sub Page_Load(...)
If CType(Session("started"), Boolean) = False Then
WriteLogin()
Else
WriteLogout()
End If
End Sub

Private Sub WriteLogin()
btnLogin.Text = "LOGIN"
btnLogin.PostBackUrl = "../login.aspx"
End Sub

Private Sub WriteLogout()
btnLogin.Text = "LOGOUT"
End Sub

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
If CType(sender, System.Web.UI.WebControls.LinkButton).Text = "LOGOUT"
Then
Session.Abandon()
WriteLogout()
End If
End Sub

The problem I'm having is, I have to click on 'LOGOUT' twice to work. I'm
thinking the Session.Abandon statement doesn't really work until the page
finishes processing and the content is flushed to the client. That confused
me, though, because the btnLogin.Text still says 'LOGOUT' after the first
click. What is happening here?

Everything that happens in the same request as the Session.Abandon still
has the Session state. At the next requesty the sessionstate will be
cleared.

//Rutger

--

//Rutger

DoDotNet@KICKTHIS_Gmail.com
www.RutgerSmit.com
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RC | last post by:
hi, I now got a session ID. I want to try to resume a session by closing the current browser and open a new one. Then pass the session ID in URL query string on new browser to resume the...
2
by: Hardin | last post by:
I have an app that uses the sessionID to track user navigation and usage through the application. It works fine except in one case: There is a point in the application where I want to "close"...
4
by: Hugo Flores | last post by:
Hi all, I noticed that there are three methods that can remove session variables Session.Clear() Session.RemoveAll() Session.Abandon() Now my question as is stated on the subject, what is...
3
by: Ricardo Q.G. | last post by:
in production environment we started to have a memory consumption problem at "asp.net wp". after a hard work we have discovered that Session.Abandon() does not reduce references to objects added to...
4
by: ad | last post by:
I use the Login controls of Asp.net 2.0 in my program. I want to logout a user by program, I try Session.Abandon() for this. But I found that the user is the same after I execute Session.Abandon()....
10
by: Li Pang | last post by:
Hi, I created a html page from which I give a link to another web site. The new site is opened in a new window. When I opened multiple windows, they all have the same SessionID. I want ot know...
1
by: pulaki | last post by:
Greetings and thank you! I am passing form data to a distant server that is out of my control. The destination server (posting to) rejects all postings beyond ONE from the same session ID. I...
0
by: 'Mani | last post by:
Hi All, I need to abandon a different session and want to know how to do this. Session.Abandon() will abndon only the current session associated with the current request. But, my necessity is...
2
by: Nathan Sokalski | last post by:
I have an application that is using Session state. On one page, I use the Session.Add() method to create the Key/Value pair for the first time. I am then sent to another page using...
16
by: Jonathan Wood | last post by:
Greetings, I was wondering if anyone here has a good understaning of the Session object. I know there are options like the Session.Abandon method and the regenerateExpiredSessionId setting,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.