来自于:cqulyk
在一般处理程序中使用Session必须要继承IRequiresSessionState接口
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.SessionState;namespace 验证码{/// <summary>/// Summary description for ValidateCheckCode1/// </summary>public class ValidateCheckCode1 : IHttpHandler,IRequiresSessionState{public void ProcessRequest(HttpContext context){context.Response.ContentType = "text/plain";string checkCodeRequested = context.Request["checkCode"];string checkCodeInSession = (string)context.Session["CheckCode"];if (checkCodeRequested.Equals(checkCodeInSession)){context.Response.Write("{\"retrunCode\":" + 0 + "}");}else{context.Response.Write("{\"retrunCode\":" + -1 + "}");}}public bool IsReusable{get{return false;}}}}
