Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Session is not letting me remove keys

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 29 Aug 2007 15:43 GMT
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 Session("mykey"),
Session.Remove("mykey"), Session.Clear(), and Session.Abandon(). None of
these seemed to make any change to Session (I have tried checking whether
Session("mykey") has a value using both Session("mykey")="" and
Session("mykey") Is Nothing). When I first go to the page that checks
whether Session("mykey") has a value before using Session.Add(), it does
recognize that is does not have a value. Also, when I tried calling
Session.Abandon() twice by clicking the Button that calls the method, it
seemed to work, but not if I call it twice one immediately after the other.
I have EnableSessionState="True" in the @Page and <pages
enableSessionState="true"> in my Web.config file. Does anybody have any idea
why I might be having this problem? Thanks.

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
Göran Andersson - 29 Aug 2007 17:26 GMT
> 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
[quoted text clipped - 12 lines]
> @Page and <pages enableSessionState="true"> in my Web.config file. Does
> anybody have any idea why I might be having this problem? Thanks.

The Remove method and the Clear method should absolutely remove the
values from the session variables collection. You must have made some
mistake when using them.

The Abandon method doesn't remove anything from the session object, it
only registers that the session will be abandoned when the request has
been completed. The current Session object is still available during the
execution of the current page. When the next page is requested, a new
Session object will be created.

Signature

Göran Andersson
_____
http://www.guffa.com

sloan - 29 Aug 2007 20:55 GMT
//
The Abandon method doesn't remove anything from the session object, it
only registers that the session will be abandoned when the request has
been completed. The current Session object is still available during the
execution of the current page. When the next page is requested, a new
Session object will be created.
//

Ditto on that.  The Abandon will "trick you" until you figure out that it
happens after the execution of the current page.

One of the reasons I wrote this:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!151.entry

was because I had a better Remove and Clear methods to call.

>> 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
[quoted text clipped - 22 lines]
> execution of the current page. When the next page is requested, a new
> Session object will be created.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.