怎么在Handler中使用Session

默认情况下,Handler中无法调用Session。我查了一下,这么做就OK了:

1.引入命名空间:

using System.Web.SessionState;

2.继承接口:

public class TestHandler : IHttpHandler, IRequiresSessionState

3.调用即可:

 public void ProcessRequest(HttpContext context)
  {

   context.Session["love"] ="jss";

  }

原文地址:https://www.cnblogs.com/bigguai/p/2624737.html