【原】在一般处理程序中设置session
2015-04-26 22:28
288 查看
using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Web; namespace Itcast.Mall.WebApp.Handlers { /// <summary> /// Vcode 的摘要说明 /// </summary> public class Vcode : IHttpHandler,System.Web.SessionState.IRequiresSessionState { public void ProcessRequest(HttpContext context) { var code = CaptchaHelper.CreateRandomCode(4); //类要实现System.Web.SessionState.IRequiresSessionState,这个才能设置session,否则会报错; context.Session["user_vcode"] = code; var img = CaptchaHelper.DrawImage(code, 20, background: Color.White); context.Response.ContentType = "image/gif"; context.Response.BinaryWrite(img); } public bool IsReusable { get { return false; } } } }
相关文章推荐
- C#一般处理程序设置和读取session(session报错未将对象引用设置到对象的实例解决)
- C#一般处理程序设置和读取session(session报错“未将对象引用设置到对象的实例”解决)
- 一般处理程序(.ashx)中session的使用方法
- ASP.NET:在一般处理程序中通过 Session 保存验证码却无法显示图片?
- .net System.Web.HttpContext.Current.Session 获取值出错(一般处理程序中出错)
- MVC、控件、一般处理程序中的session and cookie
- ASP.NET中在一般处理程序中使用session的简单介绍
- C#一般处理程序中使用Session(转帖)
- asp.net中一般处理程序中添加session
- 20151230:在一般处理程序页面使用Session<转>
- C#一般处理程序中使用Session
- 【asp】一般处理程序中使用Session
- 一般处理程序不能使用Session的问题
- 关于一般处理程序获取session问题
- ASP.NET的ASHX一般处理程序中Session为null且不能赋值
- asp.net中在一般处理程序中使用session
- 一般处理程序ashx中用session存储数据
- ASP.NET MVC 项目中 一般处理程序ashx 获取Session
- 一般处理程序获取session值
- 一般处理程序中Session的用法