导入命名空间:
using System.Web.SessionState;
实现IRequiresSessionState接口
using System; using System.Web; using System.Web.SessionState; public class Test : IHttpHandler,IRequiresSessionState{ public void ProcessRequest (HttpContext context) { context.Session["Key"] = "Value"; } public bool IsReusable { get { return false; } } }