Session 与 HttpContext.Current.Session

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010673842/article/details/80745436

Session 其实就是Page.Session , 它的生成其实就是对 HttpContext.Current.Session 的一个引用. Session 和 HttpContext.Current.Session 不同的地方在于Session 的生成依赖于 page.使用也受限制.

所以一般这两种session的使用习惯为 HttpContext.Current.Session 应用于独立的类里面, Session 使用在页面对应的behind 后台页面中,如果是 static 修饰的方法,也需要使用 HttpContext.Current.Session , Page.Session 只是 HttpContext.Current.Session 在Page生成只有的一个方便的引用而已.

猜你喜欢

转载自blog.csdn.net/u010673842/article/details/80745436