使用ashx一般处理程序,读取不到Session的问题

public class RandomCode : IHttpHandler, System.Web.SessionState.IRequiresSessionState //这里就是实现的接口
{
     public void ProcessRequest(HttpContext context)
     {
         string checkCode = GetRandomCode(5);
         context.Session["CheckCode"] = checkCode;  //不实现接口 这个Session对象就是空的,会报未将对象引用到实例!
         SetPageNoCache();
         CreateImage(checkCode);
      }
 }

 

posted @ 2022-07-15 09:26  ~且听风吟~  阅读(122)  评论(0)    收藏  举报