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.