Is there a difference between Session.Clear() and Session.RemoveAll()? The descriptions and documentation pages seem to say exactly the same thing, but I am assuming there must be some reason for creating two functions, right? Thanks.
+5
A:
Absolutely the same. RemoveAll
calls Clear
internally. From Reflector:
public sealed class HttpSessionState : ICollection, IEnumerable
{
...
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void RemoveAll()
{
this.Clear();
}
...
}
Darin Dimitrov
2010-10-14 08:24:39
nice explanation............
Nishant
2010-10-18 13:32:15
+1
A:
To be save you can always just call them all like so....
Session.Clear()
Session.Abandon()
Session.RemoveAll()
VB.NET example, I am sure all you need to do is place the ; at the end of each of them. This did the trick for me as I had some problems with my Session before where they were not removed.
Etienne
2010-10-14 08:29:12
Note: Clear and RemoveAll just remove all entries (the user keeps the same SessionId); Abandon ends the entire session (the user gets a new SessionId).
Hans Kesting
2010-10-14 08:47:19