HttpHandler 读取Session

继承自IHttpHandler的类要实现两个接口:ProcessRequest和IsReusable
但还不能使用Session,要使用Session需要下面的步骤处理:
1、先引用System.Web.SessionState 这个命名空间,
2、如果是要在HttpHandler 中读取Session的内容,就要在实现IHttpHandler 的类中同时实现IReadOnlySessionState 这个接口。
3、如果是要在HttpHandler 中读写Session的内容,就要在实现IHttpHandler 的类中同时实现IRequiresSessionState
例:
public class ProductPayEntry : IHttpHandler, IReadOnlySessionState
public class ProductPayEntry : IHttpHandler, IRequiresSessionState

原文地址:https://www.cnblogs.com/fromchaos/p/1633494.html