Session.Clear()与Session.RemoveAll()

Session.Clear()Session.RemoveAll()是否有区别?

说明和文档页面似乎说完全一样的东西,但我假设必须有一些理由来创build两个function,我是对的吗?

为了节省,你总是可以像所有这样打电话给他们….

 Session.Clear() Session.Abandon() Session.RemoveAll() 

VB.NET的例子,我相信你所要做的就是放置; 在他们每个的结尾。 这对我来说是个窍门,因为我之前的会话遇到了一些问题,之前他们没有被删除。

绝对一样。 RemoveAll调用内部Clear 。 从reflection器:

 public sealed class HttpSessionState : ICollection, IEnumerable { ... [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public void RemoveAll() { this.Clear(); } ... }