Example #1
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            RequestVariable _request = RequestVariable.Current;

            string validateCode;
            string type = _request.Get("type", Method.Get, string.Empty);

            string isStyleType = _request.Get("isstyletype", Method.Get, "0");

            string id = _request.Get("id", Method.Get, string.Empty);

            byte[] image;

            if (isStyleType == "1")
            {
                ValidateCodeType validateCodeType = ValidateCodeManager.GetValidateCodeType(type);

                if (validateCodeType == null)
                {
                    return;
                }

                image = validateCodeType.CreateImage(out validateCode);
            }
            else
            {
                image = MaxLabs.bbsMax.ValidateCodes.ValidateCodeManager.CreateImage(type, out validateCode);
            }

            context.Session[Consts.ValidateCode_SessionKey_Prefix + type.ToLower() + id.ToLower().Trim()] = validateCode;

            context.Response.Clear();
            context.Response.ContentType = "image/gif";
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetNoStore();
            context.Response.BinaryWrite(image);
            context.Response.End();
        }