zoukankan      html  css  js  c++  java
  • 【原】在一般处理程序中设置session

    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;
                }
            }
        }
    }
  • 相关阅读:
    [ARC117F]Gateau
    [ARC117D]Miracle Tree
    [loj3504]支配
    [gym102511K]Traffic Blights
    [loj3501]图函数
    [loj3503]滚榜
    [loj3500]矩阵游戏
    [loj2135]幻想乡战略游戏
    [cf720D]Slalom
    [cf1349E]Slime and Hats
  • 原文地址:https://www.cnblogs.com/gebenhagen/p/4458561.html
Copyright © 2011-2022 走看看