默认情况下,Handler中无法调用Session。我查了一下,这么做就OK了:
1.引入命名空间:
using System.Web.SessionState;
2.继承接口:
public class TestHandler : IHttpHandler, IRequiresSessionState
3.调用即可:
public void ProcessRequest(HttpContext context)
{
context.Session["love"] ="jss";
}