473,569 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session.Abandon

I have an <asp:LinkButt on 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.PostBa ckUrl = "../login.aspx"
End Sub

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

Private Sub btnLogin_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnLogin.Click
If CType(sender, System.Web.UI.W ebControls.Link Button).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 2582
Random wrote:
I have an <asp:LinkButt on 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.PostBa ckUrl = "../login.aspx"
End Sub

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

Private Sub btnLogin_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnLogin.Click
If CType(sender, System.Web.UI.W ebControls.Link Button).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@KICKTH IS_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
2667
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 session that is running at the closed browser. Is it possible to resume a session like that? Any sample code provided?
2
4257
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" the user's tracking and handle the user as if he had just logged on. To do that, I need a new sessionID. But even if I call Session.Abandon(), the...
4
1878
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 the best way to end a session?
3
3753
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 the session and not reduce memory use. in Session_End function at Global.asax file we have added the following lines of code: == == == == == ==...
4
11232
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(). I thought that Session.Abandon() can break the connection of current user, but I fail How can I logout a user by program?
10
2173
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 how to open the windows with different sessionID. Thanks
1
6865
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 am trying to get around this...my postings are valid but I can't get the programmers on the other end to accomodate me. I am doing the following: ...
0
1258
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 different. I have this authentication object whose sliding expiration value in the cache is less than the session timeout value. I want to abandon...
2
1485
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 Response.Redirect(). On the page I am sent to, I can view the Session's value using Session("mykey"), but it will not let me remove or modify it. I have tried...
16
1822
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, although I do not understand what they do. Can anyone tell me if it's possible for a recycled session to still contain the old data? I had a couple...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.