在 IHttpHandler 的实现中访问 Session,此实现必须同时实现标记接口 System.Web.SessionState.IRequiresSessionState,才可以对 Session 进行读写
在页面中<asp:Image ID="Image1" runat="server" ImageUrl="~/Handler.ashx" /><br />
请输入验证码:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage=" 验证码错误! "
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
然后就可以在像BUTTON中的CLICK事件通过IsValid 来判断是否通过验证。